Skip to main content

Back up & restore database

This section outlines how to perform database backups for your beacon node and validator client. The validator client services expose an HTTP backup endpoint which is the safest way to trigger a database backup.

Performing backups while the client is running is not safe

If you perform backups by manually copying the database while the client is running, you risk copying a corrupted database! You might be copying the folder right when the client is in the middle of writing data to the database, and could end up with a bad backup.

Beacon node

Backing up the database manually

Your first need to find your base directory. If you don't usually run your beacon node with the --datadir option, then you can find the base directory by running your beacon node with the --help option. It will vary depending the operating system you use.

For MacOS, it is:

    --datadir value      Data directory for the databases. (default: "/Users/<user>/Library/Eth2")

If you usually run your beacon node with the --datadir option, then your base directory is the one specified by the --datadir option.

Finally, your database is located in the beaconchaindata subdirectory, at the beaconchain.db file.

Restoring from a backup

Ensure your beacon node is turned off if restoring a backup. You can restore a beacon chain DB from a backup file with the following command:

Using the Prysm installation script

prysm.sh beacon-chain db restore --restore-source-file=/path/to/backup --restore-target-dir=/path/to/desired/datadir

Using Bazel

bazel run //cmd/beacon-chain -- db restore --restore-source-file=/path/to/backup --restore-target-dir=/path/to/desired/datadir

Validator client

Backing up the database manually

Stop the validator client before copying its database files to avoid capturing a partially-written state.

Your first need to find your base directory. If you don't usually run your validator client with the --datadir option, then you can find the base directory by running your validator client with the --help option. It will vary depending on the operating system you use.

The validator database file is located at validator.db inside your data directory.

Default backup output directory

When a programmatic backup is triggered (for example, by tooling that calls the Backup method directly), the output is written to the backups/ subdirectory of your data directory — for example, $DATADIR/backups/prysm_validatordb_<timestamp>.backup.

Removed and deprecated flags

The --db-backup-output-dir flag has been removed. The --enable-db-backup-webhook flag is deprecated and no longer has any effect — the /db/backup HTTP endpoint is no longer registered by the validator client.

Restoring from a backup

Ensure your validator client is turned off if restoring a backup. You can restore a validator DB from a backup file with the following command:

Using the Prysm installation script

prysm.sh validator db restore --restore-source-file=/path/to/backup --restore-target-dir=/path/to/desired/datadir

Using Bazel

bazel run //cmd/validator -- db restore --restore-source-file=/path/to/backup --restore-target-dir=/path/to/desired/datadir