How to backup with restic to S3 compatible storage

restic: Examples — restic 0.14.0 documentation
gist: backup with restic and S3 · GitHub

Start local MinIO

docker run \
  -p 9000:9000 \
  -p 9001:9001 \
  --name localminio \
  -v ~/minio/data:/data \
  -e "MINIO_ROOT_USER=AKIAIOSFODNN7EXAMPLE" \
  -e "MINIO_ROOT_PASSWORD=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY" \
  quay.io/minio/minio server /data --console-address ":9001"

Note: Minio example is for local testing only, use S3 compatible object storage in case of production setup

Initialize Restic Repo with S3

export RESTIC_REPOSITORY="s3:http://localhost:9000/restic-demo"
export AWS_ACCESS_KEY_ID="AKIAIOSFODNN7EXAMPLE"
export AWS_SECRET_ACCESS_KEY="wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY"
export RESTIC_PASSWORD="secret"
restic init

Take backup

cd /home/frappe/frappe-bench
restic backup sites

List snapshots

restic snapshots

repository 4cd7ac50 opened successfully, password is correct
ID        Time                 Host            Tags        Paths
-------------------------------------------------------------------------------------------
369ee669  2022-03-11 22:00:24  develop-laptop             /home/frappe/frappe-bench/sites
-------------------------------------------------------------------------------------------
1 snapshots

Restore backup

cd /home/frappe/frappe-bench
restic restore 369ee669 --target .
2 Likes

How will the database backup / restore will work using this ?

For small databases check this frappe_docker/docs/backup-and-push-cronjob.md at main · frappe/frappe_docker · GitHub

  1. bench --site all backup, this command will backup all sites and keep the dump under sites directory.
  2. restic snapshots || restic init, this command will check for restic repo or initialize it.
  3. restic backup sites, this command takes the snapshot of sites directory where sites, their files and their backups are.

In case the database size is over 50GB, it will be faster and efficient to take snapshot backups with maria-backup instead of using bench --site all backup.