Restore a Solr collection

You can restore a Solr collection from a backup stored on either a remote cluster or the local cluster using the solrctl utility. You must pass a unique request identifier as part of the restore command in the solrctl utility while initiating the restore operation for tracking the process.

If you are using a secure (Kerberos-enabled) cluster, specify your jaas.conf file by adding the following parameter to each command:
-jaas /path/to/jaas.conf
If TLS is enabled for the Solr service, specify the truststore and password by using the ZKCLI_JVM_FLAGS environment variable before you begin the procedure:
export ZKCLI_JVM_FLAGS=" \"
  1. If you are restoring from a backup stored on a remote cluster, copy the backup from the remote cluster to the local cluster. If you are restoring from a local backup, skip this step.

    Run the following commands on the cluster to which you want to restore the collection:

    hdfs dfs -mkdir -p /path/to/restore-staging
    hadoop distcp <protocol>://<namenode>:<port>/path/to/backup /path/to/restore-staging

    For example:

    • HDFS protocol:
      hadoop distcp hdfs:// /path/to/restore-staging
    • WebHDFS protocol:
      hadoop distcp webhdfs:// /path/to/restore-staging
  2. Start the restore procedure. Run the following command:
    solrctl collection --restore <restoreCollectionName> -l <backupLocation> -b <snapshotName> -i <requestId>

    Make sure that you use a unique <requestID> each time you run this command.

    For example:

    solrctl collection --restore tweets -l /path/to/restore-staging -b tweets-201803281043 -i restore-tweets
  3. Monitor the status of the restore operation. Run the following command periodically:
    solrctl collection --request-status <requestId>

    Look for <str name="state"> in the output. For example (emphasis added):

    solrctl collection --request-status restore-tweets
     <?xml version="1.0" encoding="UTF-8"?> <response> <lst name="responseHeader"> <int name="status"> 0</int> <int name="QTime"> 1</int> </lst> \
    <lst name="status"> <str name="state"> completed</str> <str name="msg"> found restore-tweets in completed tasks</str> </lst> </response>

    The state parameter can be one of the following:

    • running: The restore operation is running.
    • completed: The restore operation is complete.
    • failed: The restore operation failed.
    • notfound: The specified <requestID> does not exist.