mirror of
https://github.com/deuill/coreos-home-server.git
synced 2024-09-21 13:40:45 +00:00
Alex Palaistras
4fc786219a
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.
20 lines
946 B
Desktop File
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
|