Backup and restore¶
The following service modules support backups:
Backup and restore functionality is implemented with Restic.
Storage providers¶
At the time of writing Restic supports the following storage backends:
- Local
- SFTP
- REST Server
- Amazon S3
- Minio Server
- Wasabi
- Alibaba Cloud Object Storage System
- OpenStack Swift
- Backblaze B3
- Microsoft Azure Blob Storage
- Google Cloud Storage
- Other services vis RClone
Configuring backups¶
Backup options are set inside the backup
section of supporting modules.
backup.nix | |
---|---|
By default, backups are scheduled daily. This can be modified through the schedule option which follows the same format as systemd.time.
To access a Restic repository, a password (also called a key) must be specified. This can be done via restic.passwordFile
.
And since Restic can be configured with a wide variety of storage providers, an environment file can be provided to accommodate their configuration. When using an Amazon S3 backend for example the environment file might look like this:
aws.env | |
---|---|
For a detailed list of options please see here.
Systemd services¶
When backups are enabled several new Systemd services and timers will be introduced to facilitate the backup process.
For an instance of Geth named sepolia
for example, the following services will be added:
geth-sepolia-metadata.service
which captures metadata such as chain height and persists it in the state directory.geth-sepolia-metadata.timer
which triggers the metadata service every 10 seconds by default. This interval is configurable via metadata.interval.geth-sepolia-backup.service
which is responsible for stoppinggeth-sepolia.service
, backing up its state directory, and restarting it.geth-sepolia-backup.timer
which triggers the backup service once daily by default. This schedule is configurable via backup.schedule.
Restoring from backup¶
Restore options are set inside the restore
section of supporting modules and share many of the same config options as
backups.
restore.nix | |
---|---|
The one key difference is the snapshot
option which details which snapshot to restore from. This can be latest
as
seen in the example above, or a specific snapshot id as listed by running restic snapshots
:
Note: restoring from backup will only be attempted if the state directory for the service in question is empty. The presence of any files will cause the restoration attempt to be aborted.
This means it is safe to leave the restore config in place as it only has an effect when initialising a fresh instance.