docker-volume-backup
This Docker container automates Restic backups with scheduling and Docker container management.
1.4K
This Docker container automates backups using Restic, with support for scheduled backups and Docker container management during the backup process.
Required:
RESTIC_REPOSITORY: The repository location where backups will be stored (e.g., "rclone:gdrive:/backup")RESTIC_PASSWORD: Password for the Restic repositoryOptional:
BACKUP_CRON: Cron expression for scheduling backups (e.g., "* * * * *")PRUNE_CRON: Cron expression for scheduling pruning operationsDOCKER_STOP_CONTAINERS: Container names to stop during backup (e.g., "mysql-container")RESTIC_FORGET_ARGS: Arguments for the restic forget command (e.g., "--prune --keep-last 2")RUN_ON_STARTUP: Set to "true" to run backup immediately on container startCHECK_CRON: Cron expression for scheduling repository health checks (e.g., "51 20 * * *")RESTIC_CHECK_ARGS: Arguments for the restic check command (e.g., "--read-data")TZ: Timezone for the container (e.g., "Asia/Karachi")services:
backup:
depends_on:
- mysql
image: zeeemughal/docker-volume-backup
environment:
- TZ=Asia/Karachi
- RESTIC_REPOSITORY=rclone:gdrive:/backup
- BACKUP_CRON=* * * * *
- PRUNE_CRON=* * * * *
- RESTIC_FORGET_ARGS=--prune --keep-last 2
- RUN_ON_STARTUP=true
- CHECK_CRON=51 20 * * *
- RESTIC_CHECK_ARGS=--read-data
- DOCKER_STOP_CONTAINERS=mysql-container
- RESTIC_PASSWORD=your_password
volumes:
- mysql_data:/data/backup
- /var/run/docker.sock:/var/run/docker.sock
- ~/.config/rclone:/root/.config/rclone
mysql:
image: mysql:8.0
container_name: mysql-container
restart: unless-stopped
ports:
- "3306:3306"
environment:
MYSQL_ROOT_PASSWORD: rootpassword
MYSQL_DATABASE: mydatabase
MYSQL_USER: myuser
MYSQL_PASSWORD: mypassword
volumes:
- mysql_data:/var/lib/mysql
networks:
- mysql_network
volumes:
mysql_data:
To restore from backup, uncomment the following lines in your docker-compose.yml:
services:
backup:
image: zeeemughal/docker-volume-backup
environment:
- RESTIC_REPOSITORY=rclone:gdrive:/backup
- RESTIC_PASSWORD=your_password
volumes:
- mysql_data:/data/backup
- /var/run/docker.sock:/var/run/docker.sock
- ~/.config/rclone:/root/.config/rclone
entrypoint:
- "/bin/sh"
- "-c"
- "restic restore latest --target /"
restart: "no"
volumes:
mysql_data:
external: true
On startup:
RUN_ON_STARTUP is set to true, executes a backup immediatelyScheduled Operations:
BACKUP_CRON schedulePRUNE_CRON scheduleCHECK_CRON scheduleDuring backup:
DOCKER_STOP_CONTAINERS)During pruning:
RESTIC_FORGET_ARGS/root/.config/rcloneTZ variable)Content type
Image
Digest
sha256:7f335f08b…
Size
52.2 MB
Last updated
over 1 year ago
docker pull zeeemughal/docker-volume-backup