coreos-home-server/host/base/systemd/container-volume-backup@.service
Alex Palaistras 4fc786219a container-volume-backup: Use symlink to latest file
Pointers to the latest backup are useful for restore operations, but
should be ignored in all other cases, and thus are more appropriately
handled as symbolic links.
2022-02-07 11:10:38 +00:00

20 lines
946 B
Desktop File

[Unit]
Description=Backup for Container Volume %I
[Service]
Type=oneshot
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:/backup:z \
docker.io/debian:bullseye-slim -c \
'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 . && \
cd /backup && ln --symbolic --force "$name.tar.gz" %i-latest.tar.gz'
[Install]
WantedBy=multi-user.target