Implement minor improvements for volume backups
Container volume backups will now be skipped if no changes have been made in source files against the latest backup. In addition the default timer has been changed for performing backups once a day, at 02:00, likely a time where there's less traffic on the server.
This commit is contained in:
parent
c8eed1c3db
commit
4636730d32
|
@ -7,11 +7,13 @@ SyslogIdentifier=%N
|
|||
ExecStartPre=/bin/install --mode 0700 --directory %S/backups/coreos-home-server/%i
|
||||
ExecStart=/bin/podman run --replace --rm --name %p-%i --entrypoint /bin/bash \
|
||||
--volume %i:/data:z,ro \
|
||||
--volume %S/backups/coreos-home-server/%i:/backups:z \
|
||||
--volume %S/backups/coreos-home-server/%i:/backup:z \
|
||||
docker.io/debian:bullseye-slim -c \
|
||||
'name="%i-$(date +%%w%%H)" && \
|
||||
tar -cvpzf "/backups/$name.tar.gz" -C /data . && \
|
||||
ln --force "/backups/$name.tar.gz" /backups/%i-latest.tar.gz'
|
||||
'test -f /backup/%i-latest.tar.gz && \
|
||||
test "$(find /data -type f -newer /backup/%i-latest.tar.gz -print -quit | wc -l)" -eq 0 && exit 0; \
|
||||
name="%i-$(date +%%w%%H)" && \
|
||||
tar --verbose --create --gzip --file "/backup/$name.tar.gz" --directory /data . && \
|
||||
ln --force "/backup/$name.tar.gz" /backup/%i-latest.tar.gz'
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
Description=Scheduled Backup for Container Volume %i
|
||||
|
||||
[Timer]
|
||||
OnCalendar=00/12:30
|
||||
RandomizedDelaySec=15m
|
||||
OnCalendar=02:00
|
||||
RandomizedDelaySec=10m
|
||||
|
||||
[Install]
|
||||
WantedBy=timers.target
|
||||
|
|
|
@ -7,10 +7,10 @@ Type=oneshot
|
|||
SyslogIdentifier=%N
|
||||
ExecStart=/bin/podman run --replace --rm --name %p-%i --entrypoint /bin/bash \
|
||||
--volume %i:/data:z \
|
||||
--volume %S/backups/coreos-home-server/%i:/backups:z,ro \
|
||||
--volume %S/backups/coreos-home-server/%i:/backup:z,ro \
|
||||
docker.io/debian:bullseye-slim -c \
|
||||
'test -n "$(ls -A /data)" && echo "Volume %i is not empty, skipping." && exit 0; \
|
||||
tar -xvpf "/backups/%i-latest.tar.gz" -C /data'
|
||||
tar --verbose --extract --file "/backup/%i-latest.tar.gz" --directory /data'
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
Loading…
Reference in New Issue