SIP-12 proposes a collection of changes to Solr's existing backup/restore functionality. Among these is support for a new backup format that will allow backups to be done incrementally. This page is intended to detail the specific file layout being proposed. For other aspects of the incremental backup proposal or other aspects of the SIP, see the main proposal page here.
Backups under the proposed incremental format would create a file tree like the one shown below at a given "location" (i.e. location parameter value) in the backup repository. Each "location" can store an arbitrary number of backups, organized at the highest level by the "backup name" (usually but not always the name of the collection being backed up).
/backup_location
/techproducts
/backup_0.properties
/backup_1.properties
/shard_backup_metadata
/md_shard1_id_0.json
/md_shard2_id_0.json
/md_shard1_id_1.json
/md_shard2_id_1.json
/index
/0DD2971A-53D6-4224-A49B-8AC90D158F97
/1AA2CF56-BFA0-40D5-8B9B-5CAD47B07396
...
/zk_backup_0
conf/
<configset files>
state.json
...
/zk_backup_1
... |
The file listing above shows a single backup "location" which contains two incremental backups ("0", and "1"). Several different classes of files can be seen:
Most of the files in the listing above are either Lucene index files or ZooKeeper data backups. The only new files are the collection and shard-level metadata files for each backup. These are worth a closer look.
The "collection-level" metadata file for each backup includes a variety of information about the backup, as shown below.
backupName:<...> collection:<name of the collection> collectionAlias:<..> collection.configName:<..> startTime:<time of the backup creation> index.version:<LUCENE_8_2_0> shard1.md:<metadata file for shard1> shard2.md:<metadata file for shard2> numberOfIndexFiles:<> indexSize:<> |
This file holds a mix of metadata (collection, startTime, index.version, etc.) and navigational pointers used to lookup information for each shard (shard1.md, shard2.md). When creating a backup this file is written last, allowing backup code to rely on its presence as an indicator that the backup was completed successfully.
An example "shard-level" metadata JSON file is shown below. It holds information about each index file required to restore the shard in question. This includes all index files just uploaded as well as any index files uploaded by previous backups but that are still used by the shard. Metadata is stored for each Lucene index file, including its original filename, the unique name given to the file for storage in the backup repository, and checksum and size information.
The unique filenames are required to avoid name conflicts between identically named files from different shards. (Fun-fact: name-conflict scenarios also crop up with single-shard collections following leadership changes, decisions to delete the entire index, etc.
The checksum and size information stored with each file allows Solr to tell which files have changed since the last incremental update, and avoid uploading these files.
"0DD2971A-53D6-4224-A49B-8AC90D158F97" : {
"fileName" : "segments_10"
"checksum" : "1238971231e6239"
"size" : 101013
},
"1AA2CF56-BFA0-40D5-8B9B-5CAD47B07396" : {
...
},
...
} |
As a way to show how this file format allows incremental backups to be done, let's walk through two backups done on the 'techproducts' collection. This walkthrough focuses narrowly on the files read and written by Solr during the backup process. It omits details such as communication between Solr nodes, overseer messages, etc. for brevity and because these pieces are mostly unaffected by this SIP.
An excited first-time Solr user has just stood up a 'techproducts' collection on their SolrCloud cluster. They want to take a snapshot before tweaking some settings.
The Solr user further grooms their techproducts catalog. ("What are those currency docs doing in there anyways?") They're happy with the results and want to backup again.
Solr gathers the index files on the shard leader. For each, it checks whether the file has already been uploaded according to the records in md_shard1_id_0. If the shard-metadata file has an entry for a given local file, and the recorded checksum and file-size match those exhibited by the local file, the local file is skipped over. Otherwise the file is uploaded as in step (3) from "Initial Backup".