Validate backup files with asrestore
When you run asrestore with --validate, it scans backup files and reports parsing errors.
Validate mode works with options such as --directory, --input-file, or --directory-list to specify backups for asrestore. It ignores data selection and Aerospike connection options because it does not connect to the database.
To validate backups in an Amazon S3 bucket, you must still connect to S3.
Example
The following example creates a small backup, corrupts it, then validates it.
Create a test backup
Back up a single record to a directory:
asbackup -h 127.0.0.1:3000 -n test -d test-backup-dirInspect the backup file:
cat test-backup-dir/test_00000.asbVersion 3.1# namespace test# first-file+ k S 4 key1+ n test+ d 7JEZLUt/jONdXXjTS8ply6qqyWA=+ s demo+ g 1+ t 430086781+ b 3- I foo 123- S bar 3 abc- Z baz TCorrupt the backup file
Create corruption in the backup file:
sed -i '' -e 's/S/2/g' ./test-backup-dir/test_00000.asbVerify the corruption:
cat test-backup-dir/test_00000.asbVersion 3.1# namespace test# first-file+ k 2 4 key1+ n test+ d 7JEZLUt/jONdXXjT28ply6qqyWA=+ s demo+ g 1+ t 430086781+ b 3- I foo 123- 2 bar 3 abc- Z baz TValidate the backup directory
Run asrestore in validate mode:
asrestore --validate -d test-backup-dir2023-07-19 20:48:42 UTC [INF] [94673] Starting validation of test-backup-dir2023-07-19 20:48:42 UTC [INF] [94673] Found 1 backup file(s) in test-backup-dir2023-07-19 20:48:42 UTC [INF] [94673] Validating backup files2023-07-19 20:48:42 UTC [INF] [94673] Finished validating backup file(s)2023-07-19 20:48:42 UTC [INF] [94675] validating test-backup-dir/test_00000.asb2023-07-19 20:48:42 UTC [INF] [94675] Opened backup file test-backup-dir/test_00000.asb2023-07-19 20:48:42 UTC [ERR] [94675] Invalid key type character "2" in block (line 4, col 5)2023-07-19 20:48:42 UTC [ERR] [94675] Error while parsing record2023-07-19 20:48:42 UTC [ERR] [94675] Error while parsing backup file test-backup-dir/test_00000.asb (line 4)