Skip to content

Instantly share code, notes, and snippets.

@yamatt
Created January 15, 2021 13:31
Show Gist options
  • Save yamatt/585f1b2617ec9d05aa5e0e45d7620031 to your computer and use it in GitHub Desktop.
Save yamatt/585f1b2617ec9d05aa5e0e45d7620031 to your computer and use it in GitHub Desktop.
Running Duplicity under Gnome Wayland and Systemd

Setup

Install duplicity and gnupg2

GnuPGP public keys

Configure yourself a GPG key to encrypt the data with. Note the key ID/hash to use in the duplicity-backup.service.

Remember to backup your private key separately so it is not lost when you need your backups, and so you can recover your files.

Object Storage Provider

Create yourself a place to put your backups

B2

Create an app key as per but look out for this issue with slashes in the application key.

Create yourself a URL configuration much like in the linked articles in a file called ~/.duplicity-destination-url.txt. This is simply a file that contains a single line which is the destination url for duplicity.

SystemD

Place the files duplicity-backup.service and duplicity-backup.timer under /etc/systemd/system/.

Remember you must change your username in duplicity-backup.service to your username, as well as maybe change the 1000 in XDG_RUNTIME_DIR=/run/user/1000 to your uid. You can find your uid by running id -u.

You must also change your GPG key to the ID of the key you created above.

Note in duplicity-backup.timer you can replace the line OnCalendar=daily with OnCalendar=weekly depending on what you want your backup schedule to be.

You may also not want to backup your Documents directory and backup other directories. You can find guidance in the duplicity manpage.

Now start and enable the timer.

$ sudo systemctl enable duplicity-backup.timer
$ sudo syststemctl start duplicity-backup.timer

You can also manually run the service to test it by running:

$ sudo systemctl start duplicity-backup.service

and see the output by running:

$ sudo systemctl status duplicity-backup.service

Note

  • SystemD recognises the two .service and .timer files as a pair because of their file name.
[Unit]
Description=Backup user data to B2 using Duplicity
RefuseManualStart=no
RefuseManualStop=yes
[Service]
User=matt
Type=simple
ExecStart=bash -c '/usr/bin/notify-send "About to start backup" && /usr/bin/duplicity --encrypt-key 2D137F09F794214A ~/Documents/ $(cat ~/.duplicity-destination-url.txt) && /usr/bin/notify-send "Backup Complete" || /usr/bin/notify-send "Backup failed"'
[Unit]
Description=Trigger Duplicty Backup every day
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment