This image combines alpine + supercronic and restic for easy backup sidecar containers
2.5K
This repo contains a dockerfile which allows running a restic cron job inside a
docker container.
Link to Github
I want to be able to run restic backups on a schedule. This image is intended as sidecar to other services. It should mount the same volumes as the main service and run the restic backups on a schedule.
src/crontab (see Chrontab content below)/opt/cron/crontab!
volumes:
- ./src/crontab:/opt/cron/crontab
restic-cron:
image: vservtech/restic-cron-docker:latest
volumes:
- ./src/crontab:/opt/cron/crontab
user: "${MY_UID}:${MY_GID}"
docker compose up -d
# This crontab is evaluated by golangs cronexpr inside supercronic
# supports seconds-based resolution (normal cronjobs are minutes-based)
# Allowed fields: https://github.com/aptible/supercronic/tree/master/cronexpr#implementation
# Field name Mandatory? Allowed values Allowed special characters
# ---------- ---------- -------------- --------------------------
# Seconds No 0-59 * / , -
# Minutes Yes 0-59 * / , -
# Hours Yes 0-23 * / , -
# Day of month Yes 1-31 * / , - L W
# Month Yes 1-12 or JAN-DEC * / , -
# Day of week Yes 0-6 or SUN-SAT * / , - L #
# Year No 1970–2099 * / , -
# Run every minute
*/1 * * * * echo "hello every minute: $(date -u + \"%Y-%m-%dT%H:%M:%SZ\")"
# Run every second
*/1 * * * * * * echo "hello every second: $(date -u +"%Y-%m-%dT%H:%M:%SZ")"
# Run once every hour
# @hourly echo "$SOME_HOURLY_JOB"
You can use ash (default on alpine linux) or bash scripts in your crontab.
src/bash-demo.sh
echo "hello from bash $(date -u +"%Y-%m-%dT%H:%M:%SZ")"
/opt/cron/ because this folder is configured for variable user/group the
container could be running under!
volumes:
- ./src/bash-demo.sh:/opt/cron/bash-demo.sh
*/1 * * * * * * /opt/cron/bash-demo.sh
chmod +x src/bash-demo.shsupercronicInstructions: https://github.com/aptible/supercronic
supercronic -help
supercronic -version
resticPreparation: Create a restic repository, if not already done. See: https://restic.readthedocs.io/en/latest/030_preparing_a_new_repo.html
Backup some data: https://restic.readthedocs.io/en/latest/040_backup.html
bun run shell to get shell inside container/bin/ashbun run shell to get shell access into the containerrestic versionbun run deploy (runs build, tag:latest and push:version and
push:latest)Content type
Image
Digest
sha256:4dc3ea823…
Size
96.8 MB
Last updated
8 months ago
docker pull vservtech/restic-cron-docker