Last active
May 19, 2023 17:01
-
-
Save klutchell/8ec4ad958eecbdc9bd3bcf81c38716c7 to your computer and use it in GitHub Desktop.
scheduled duplicity backups with systemd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# description: | |
# - once per day perform backup of $HOME | |
# - every 14th backup will be a full backup (~2 weeks) | |
# - delete all backups older than the 4th most recent full backup (~8 weeks) | |
# - exclude files larger than 100M | |
# usage: | |
# 1. install duplicity.service in ~/.config/systemd/user/ | |
# 2. install duplicity.timer in ~/.config/systemd/user/ | |
# 3. create ~/.duplicity and define DEST, GPG_KEY_ID, and PASSPHRASE | |
# 4. run 'systemctl --user enable duplicity.timer' | |
# 5. run 'systemctl --user start duplicity.timer' | |
# 6. if you get bus errors on debian try installing libpam-systemd via apt | |
[Unit] | |
Description=Duplicity backup and cleanup | |
[Service] | |
Type=oneshot | |
EnvironmentFile=%h/.duplicity | |
ExecStartPre=-/bin/sh -c '/usr/bin/find %h -size +100M > /tmp/filelist' | |
ExecStartPre=/bin/sed -e 's/^/"/g' -e 's/$/"/g' -i /tmp/filelist | |
ExecStart=/usr/bin/duplicity --name ${HOSTNAME} --encrypt-sign-key ${GPG_KEY_ID} --exclude-filelist /tmp/filelist --full-if-older-than 14D %h ${DEST}/${HOSTNAME} | |
ExecStart=/usr/bin/duplicity --name ${HOSTNAME} --encrypt-sign-key ${GPG_KEY_ID} remove-all-but-n-full 4 --force ${DEST}/${HOSTNAME} | |
ExecStart=/usr/bin/duplicity --name ${HOSTNAME} --encrypt-sign-key ${GPG_KEY_ID} cleanup --force ${DEST}/${HOSTNAME} | |
ExecStart=/usr/bin/duplicity --name ${HOSTNAME} --encrypt-sign-key ${GPG_KEY_ID} collection-status ${DEST}/${HOSTNAME} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# description: | |
# - once per day perform backup of $HOME | |
# - every 14th backup will be a full backup (~2 weeks) | |
# - delete all backups older than the 4th most recent full backup (~8 weeks) | |
# - exclude files larger than 100M | |
# usage: | |
# 1. install duplicity.service in ~/.config/systemd/user/ | |
# 2. install duplicity.timer in ~/.config/systemd/user/ | |
# 3. create ~/.duplicity and define DEST, GPG_KEY_ID, and PASSPHRASE | |
# 4. run 'systemctl --user enable duplicity.timer' | |
# 5. run 'systemctl --user start duplicity.timer' | |
# 6. if you get bus errors on debian try installing libpam-systemd via apt | |
[Unit] | |
Description=Duplicity daily timer | |
[Timer] | |
OnCalendar=daily | |
Persistent=true | |
Unit=duplicity.service | |
[Install] | |
WantedBy=default.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment