by qmmmur · 6y ago · 0 comments
Here are my systemd files for reference.
Service:
[Unit]
Wants=network-online.target
After=network-online.target
[Service]
Type=simple
ExecStart=/bin/bash -c "/usr/bin/restic unlock && /usr/bin/restic backup --verbose --one-file-system --exclude-caches --exclude=$XDG_CACHE_HOME %h && /usr/bin/restic forget --keep-last 5 --prune && /usr/bin/restic cache --cleanup --max-age 30"
[Install]
WantedBy=default.target
Environment (fill these in with your keys): [Service]
Environment="B2_ACCOUNT_ID="
Environment="B2_ACCOUNT_KEY="
Environment="RESTIC_REPOSITORY="
Environment="RESTIC_PASSWORD="
Timer: [Timer]
OnCalendar=*-*-* 00:30:00
RandomizedDelaySec=20min
[Install]
WantedBy=timers.targethttps://fedoramagazine.org/automate-backups-with-restic-and-...
edit: one gotcha is that using "user" systemd units, they will only run when the user is logged in. So, for a personal device like a laptop, this is fine, but for a server, it might not do what you're thinking. For the server use case, you probably want to enable linger for that utility user, so that units will run even with no active logged in sessions:
# loginctl enable-linger username