This is a mini docker image that uses busybox crond to perform daily, weekly and monthly backups from a source to a target directory. It has been created with the intent to backup nextcloud data, where the nextcloud share is mounted via davfs. As davfs is not ... blazingly fast, I am using unison to perform the synchronization, as rsync turned out to be too slow to be useful in this context. However, this is not necessarily limited to backing up nextcloud file shares - should work for every case where you need to take somewhat structured backups/synchronization points of a directory that is available in your file system.
When brought up, this container will start crond, which in turn will run daily, weekly and monthly backup scripts.
- the daily script uses unison to synchronize
$SOURCE
to$BACKUP/daily
, every night - the weekly script uses unison to synchronize
$BACKUP>/daily
to$BACKUP>/weekly
, every week - the monthly script uses tar to create a compressed archive of
$BACKUP>/daily
to$BACKUP>/monthly
The $SOURCE
and $BACKUP
directories are declared via volume mounts when starting the docker container - e.g. like this when using docker compose:
version: '3'
services:
nxtcldbackup:
container_name: nxtcld-backup
build:
context: .
dockerfile: alpine.dockerfile
init: true
volumes:
- unison-conf:/root/.unison
- /mnt/nextcloud:/mnt/source
- /mnt/raid1/nextcloud:/mnt/backup
volumes:
unison-conf:
- once this has proved to work reasonably well, add logic to remove monthly backups older than a certain (configurable) time period
- if we're bored, might add a configuration switch to use either rsync or unison