2021-08-14 21:31:02 +00:00
|
|
|
[Unit]
|
2021-08-28 11:51:11 +00:00
|
|
|
Description=Backup for Container Volume %I
|
2021-08-14 21:31:02 +00:00
|
|
|
|
|
|
|
[Service]
|
|
|
|
Type=oneshot
|
2021-08-28 18:16:29 +00:00
|
|
|
SyslogIdentifier=%N
|
2021-08-14 21:31:02 +00:00
|
|
|
ExecStartPre=/bin/install --mode 0700 --directory %S/backups/coreos-home-server/%i
|
2021-08-28 18:16:29 +00:00
|
|
|
ExecStart=/bin/podman run --replace --rm --name %p-%i --entrypoint /bin/bash \
|
2021-08-14 21:31:02 +00:00
|
|
|
--volume %i:/data:z,ro \
|
2022-02-05 16:01:22 +00:00
|
|
|
--volume %S/backups/coreos-home-server/%i:/backup:z \
|
2021-12-26 13:31:32 +00:00
|
|
|
docker.io/debian:bullseye-slim -c \
|
2022-02-05 16:01:22 +00:00
|
|
|
'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 . && \
|
2022-02-06 20:46:20 +00:00
|
|
|
cd /backup && ln --symbolic --force "$name.tar.gz" %i-latest.tar.gz'
|
2021-08-14 21:31:02 +00:00
|
|
|
|
|
|
|
[Install]
|
|
|
|
WantedBy=multi-user.target
|