Skip to content

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:

Terminal window
asbackup -h 127.0.0.1:3000 -n test -d test-backup-dir

Inspect the backup file:

Terminal window
cat test-backup-dir/test_00000.asb
Backup file content
Version 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 T

Corrupt the backup file

Create corruption in the backup file:

Terminal window
sed -i '' -e 's/S/2/g' ./test-backup-dir/test_00000.asb

Verify the corruption:

Terminal window
cat test-backup-dir/test_00000.asb
Corrupted backup file content
Version 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 T

Validate the backup directory

Run asrestore in validate mode:

Terminal window
asrestore --validate -d test-backup-dir
Validate mode output
2023-07-19 20:48:42 UTC [INF] [94673] Starting validation of test-backup-dir
2023-07-19 20:48:42 UTC [INF] [94673] Found 1 backup file(s) in test-backup-dir
2023-07-19 20:48:42 UTC [INF] [94673] Validating backup files
2023-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.asb
2023-07-19 20:48:42 UTC [INF] [94675] Opened backup file test-backup-dir/test_00000.asb
2023-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 record
2023-07-19 20:48:42 UTC [ERR] [94675] Error while parsing backup file test-backup-dir/test_00000.asb (line 4)
Feedback

Was this page helpful?

What type of feedback are you giving?

What would you like us to know?

+Capture screenshot

Can we reach out to you?