SHOW BACKUP... WITH check_files: Check that all files belonging to a backup are in the expected location in storage. Refer to Validate backup files for an example.RESTORE... WITH schema_only: Restore the schema from the backup to verify that it is valid without restoring any rows. Refer to Validate a backup is restorable for an example.RESTORE... WITH schema_only, verify_backup_table_data: Run aschema_onlyrestore and have the restore read all rows from external storage, verify checksums, and discard the rows before writing them to disk. To useverify_backup_table_data, you must includeschema_onlyin the statement. Refer to Validate backup table data is restorable for an example.
verify_backup_table_data will take a longer time to validate a backup compared to check_files or schema_only alone. Despite that, each of these validation options provide a quicker way to validate a backup over running a “regular” restore.
Recommendations
Cockroach Labs recommends implementing the following validation plan to test your backups:- Very frequent
schema_onlyrestores: Checks your credentials, schema issues, and version compatibility. - Frequent
verify_backup_table_datarestores: Tests that all data files are present and uncorrupted. - Somewhat frequent restores: Validates a backup completely.
schema_only restore provides high confidence in the recoverability of your backup and a verify_backup_table_data restore provides a slightly higher confidence as it checks for corruptions. Only a complete RESTORE can provide full confidence in validating a backup. The actual frequency you should run backup validation tests depends on the criticality of your data, the rate of change in your database, and your organization’s disaster recovery and business continuity requirements.
Supported products
The feature described on this page is available in CockroachDB Basic, CockroachDB Standard, CockroachDB Advanced, and CockroachDB self-hosted clusters when you are running . For a full list of features, refer to .Validate backup files
UsingSHOW BACKUP with the check_files option, you can check that all that belong to a backup are present in the storage location.
-
Take a backup that we’ll use for each of the examples on this page:
-
To find a specific backup to validate in the storage location, show the stored backups in the storage location:
-
Use
SHOW BACKUP... check_fileswith a backup for validation:This will return the following output after validating that the backup files are correct and present:The output will returnfile_bytesalong with the columns you receive fromSHOW BACKUPwithoutcheck_files. Thefile_bytescolumn indicates the estimated bytes in external storage for a particular table object. For more detail on the output columns, see theSHOW BACKUPtable. -
If
SHOW BACKUP... check_filescannot read from a file, it will return an error message similar to the following:SHOW BACKUP... check_fileswill return up to ten file paths for incorrect or missing files.
Validate a backup is restorable
To validate that a backup is restorable, you can runRESTORE with the schema_only option, which will complete a restore without restoring any rows. This process is significantly faster than running a for the purposes of validation.
A schema_only restore produces close to complete validation coverage on backups. However, this restore type does not read or write from any of the SST files, which store the backed-up rows. You can use SHOW BACKUP... WITH check_files in addition to a schema_only restore to check that these SST files are present for a restore operation. Or, you can use schema_only in combination with verify_backup_table_data. Refer to Validate backup table data is restorable.
Validation of full-cluster restores with
schema_only must be run on an empty cluster in the same way as a complete . Once you have successfully validated the restore, you can destroy the test cluster.RESTORE with the schema_only option, specifying either LATEST or the specific backup you would like to restore:
new_db_name = test_movr.
Verify that the table schemas have been restored, but that the tables contain no rows:
Validate backup table data is restorable
A restore with theverify_backup_table_data option will perform a schema_only restore, and:
- Read all rows from the storage location.
- Checksum the rows to ensure they are not corrupt.
- Discard the rows before they are written to disk.
schema_only must be run on an empty cluster in the same way as a complete . Once you have successfully validated the restore, you can destroy the test cluster.
Similarly, to just schema_only restores, you’ll find the table schemas restored. If a file is not present or unreadable in the backup, you’ll receive an error.
Unlike a schema_only restore, a verify_backup_table_data restore also reads and checksums the rows to validate the backup.
It is necessary to include schema_only when you run a restore with verify_backup_table_data:

