---
title: "Validate backup files with asrestore"
description: "Validate Aerospike backup files using asrestore --validate to detect and report file parsing errors."
---

# Validate backup files with asrestore

> For the complete documentation index see: [llms.txt](https://aerospike.com/docs/llms.txt)
> 
> All documentation pages available in markdown.

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.

::: note
Validate mode cannot detect all corrupted data. The tool only identifies issues that cause errors while parsing the backup files. For more information, see [Backup File Format](https://github.com/aerospike/aerospike-tools-backup#backup-file-format).
:::

## 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

```shell
asbackup -h 127.0.0.1:3000 -n test -d test-backup-dir
```

Inspect the backup file:

Terminal window

```shell
cat test-backup-dir/test_00000.asb
```

Backup file content

```text
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

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

Verify the corruption:

Terminal window

```shell
cat test-backup-dir/test_00000.asb
```

Corrupted backup file content

```text
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

```shell
asrestore --validate -d test-backup-dir
```

Validate mode output

```text
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)
```