Restic is an open source backup program written in Golang and can run on Linux, Windows, and Mac.
Download: https://github.com/restic/restic/releases/latest
Cheat sheet[edit | edit source]
Description | Command |
---|---|
Initialize a new repository | restic init
|
Backup files | restic backup /path/to/files
|
Backup files using a file list | restic backup --files-from=$filelist
|
Backup files with a specific tag | restic backup --tag $tag /path/to/files
|
Show available snapshots | restic snapshots
|
Restore a snapshot to the given destination | restic restore $snapshotid -t $destination
|
Delete all snapshots and prune backend storage | restic forget --prune
|
Delete all snapshots except a specific tag | restic forget --keep-tag=$tag
|
To automate restic, you may want to pass in the repository password in the RESTIC_PASSWORD
environment variable.
Setup[edit | edit source]
Automate backups with cron[edit | edit source]
Add a cronjob:
# crontab -e
## Add:
## */15 * * * * . ~/.restic.env ; /usr/local/bin/restic backup --files-from=/root/restic.files --tag automated 2>> ~/restic.err >> ~/restic.log
S3 compatible backend[edit | edit source]
Define the following environment variables before running restic init
.
export AWS_ACCESS_KEY_ID="***"
export AWS_SECRET_ACCESS_KEY="***"
export RESTIC_REPOSITORY="s3:https://s3-server/bucket-name"
On Oracle Cloud, you need to generate the AWS access key id and secret under Identity & Security -> Users -> your account -> Customer Secret Keys. The S3 repository follows this format: https://<namespace>.compat.objectstorage.<region>.oraclecloud.com
, where <namespace> is given under your bucket information and region is found in your dashboard's URL.