Backup folders from environment variables with BorgBackup tool.
Build every week for the base image update, and, of course, at every commit :
I've create this image to have :
- Simple to use backup tool (by borgbackup)
- Easy management with folder with few mount
- Easy to run with internal cron (to avoid cron task on the host), optional if you have you own task manager (see ONESHOT variable).
- Easy setup with environnement variables
- MySQL backup included
- Postgres backup included
- All backups encrypted (by borgbackup)
Feel free to improve the code on the github with pull requests and questions.
Docker Hub link : https://hub.docker.com/r/azlux/borgbackup
BORG_PASSPHRASE
- borgbackup passphraseFOLDERS_TO_BACKUP_PATH
- folder path where you put the Volumes to backupBACKUP_PATH
- Backup Volume path
If MySQL or Postgres values are given, mysqldump and/or pg_dumpall will be executed and added to the backup.
MYSQL_USER
- MySQL User (with all table read access)MYSQL_PASSWORD
- MySQL PasswordMYSQL_HOST
- IP or name of the MysQL HostPOSTGRES_USER
- POSTGRES User (with all table read access)POSTGRES_PASSWORD
- POSTGRES PasswordPOSTGRES_HOST
- IP or name of the POSTGRES HostPOSTGRES_VERSION
- Version of the postgres database if different from bookworm versionBORG_KEEP_WITHIN
- keep all archives within this time interval (default:"14d"
)BORG_KEEP_WEEKLY
- number of weekly archives to keep (default:8
)BORG_KEEP_MONTHLY
- number of monthly archives to keep (default:6
)BACKUP_CRON
- Custom CRON time (0 3 * * *
:every day at 3AM by default)ONESHOT
- (true/false) Run the backup without cron (usefull if you have eternal scheduler) - False by default
See https://borgbackup.readthedocs.io/en/1.2-maint/usage/prune.html for the BORG_KEEP_XXX
variables
backup:
image: azlux/borgbackup
container_name: backup
hostname: backup
restart: on-failure
environment:
BORG_PASSPHRASE: ${BORG_PASSPHRASE}
FOLDERS_TO_BACKUP_PATH: /folder_to_backup
BACKUP_PATH: /backup
MYSQL_USER: root
MYSQL_PASSWORD: ${MARIADB_MYSQL_ROOT_PASSWORD}
MYSQL_HOST: mariadb
volumes:
- /first/path/on/host:/folder_to_backup/data1
- /second/path/on/host:/folder_to_backup/data2
- ...
- /backup/path/on/host:/backup
tmpfs: /tmp
Many people ask me for alpine image. If you want one, don't take my image.
After many years on docker, Alpine is the main source of my problems encountered. Maybe, one day they will have a stable DNS support (no reproductible issues took me so many hours to debug).