Defining a backup target in solr.xml

If you want to to define or modify a backup target, you can download, edit and reupload solr.xml from ZooKeeper.

The solr.xml of your Solr installation, which is stored in ZooKeeper, can define a backup target repository, and depending on your installation it likely has a default target pointing to HDFS.

HDFS as a backup target is still fine even if your Solr collection uses a local FS / NRTCachingDirectoryFactory, so even with local FS collections you can store your backups on HDFS.

Similarly to this, other repositories like a LocalFileSystemRepository can also be defined in the solr.xml if you want to store the backups on a location other than HDFS. However note, that if you use a local FS to store backups, each Solr host will store its backup directory locally. That is, server X will contain the backup directory snapshots.shard1, server Y will contain snapshots.shard2 and you need to copy them to a shared location in order to be able to restore them later. Because of this, it is recommended to target backups to a shared file system.

If the solr.xml does not have a backup repository at all, it defaults to the local FS repository.

  1. To define or modify a backup target, download solr.xml from ZooKeeper using the following solrctl command:
    solrctl cluster --get-solrxml solr.xml
  2. Edit the contents of the solr.xml file.
    This is an example of defining a HDFS backup target in the solr.xml file:
      <repository name="hdfs" class="org.apache.solr.core.backup.repository.HdfsBackupRepository" default="false">
        <str name="location">${solr.hdfs.default.backup.path}</str>
        <str name="solr.hdfs.home">${solr.hdfs.home:}</str>
        <str name="solr.hdfs.confdir">${solr.hdfs.confdir:}</str>
  3. Reupload the modified solr.xml file:
    solrctl cluster --put-solrxml solr.xml