This container is used to backup your data to a restic repository.
Pull the docker image from the GitHub Container Registry
docker pull ghcr.io/valentin-kaiser/backup:latest
Run the container with the following command or use docker compose
docker run -d \
--name backup \
-v /path/to/your/source:/source \
-v /path/to/your/backup:/backup \
-v /path/to/your/password:/run/secrets/backup_password \
ghcr.io/valentin-kaiser/backup:latest
/source
: The source directory to backup/backup
: The target directory to backup to a restic local repository/run/secrets/backup_password
: The password file for the restic repository
The container schedules the backup and forget scripts using cron.
Your data should be mounted to /source
and your backup to /backup
, but Restic can backup to different types of repositories.
Possible values are local
, sftp
, rest
, s3
, gs
, b2
, azure
, rclone
.
Per default the container uses a local repository. You should mount the repository to /backup
or configure it using environment variables.
To secure your backup you should use docker secrets/a password file. The password file should be mounted to /run/secrets/backup_password
.
You can fine tune restic and the backup and forget commands using the following environment variables and restic environment variables.
BACKUP_SCHEDULE
: The schedule for the backup. Default:0 0 * * *
FORGET_SCHEDULE
: The schedule for the forget command. Default:0 0 * * *
RESTIC_SOURCE
: The source directory to backup. Default:/source
RESTIC_REPOSITORY
: The backup repository. Default local directory:/backup
RESTIC_PASSWORD_FILE
: The password file for the restic repository. Default:/run/secrets/backup_password
RESTIC_BACKUP_ARGS
: The arguments for the backup command. Default:--exclude-caches --exclude-if-present=.nobackup --exclude-file=/.backupignore
RESTIC_FORGET_ARGS
: The arguments for the forget command. Default:--prune --keep-daily 7 --keep-weekly 4 --keep-monthly 6
RESTIC_COMMPRESSION
: The compression algorithm to use. Default:auto
MOUNT_LOCK_TEST
: Whether to check if the target is mounted. Default:true
MOUNT_LOCK_FILE
: The file to check for. Default:/.mounted
The container ships with four scripts:
/entrypoint.sh
: The entrypoint script ensures that the restic repository is initialized and the cron job is scheduled and daemon started/backup.sh
: The backup script runs the restic backup command and will be scheduled by cron to create new backups/forget.sh
: The forget script runs the restic forget command and will be scheduled by cron to prune old backups/restore.sh
: The restore script leads you through the restore process
The container logs to three different log files that can be found in /var/log
:
/var/log/backup.log
: The output of the backup command/var/log/forget.log
: The output of the forget command