Skip to content

Instantly share code, notes, and snippets.

@kakra
Last active October 16, 2016 07:28
Show Gist options
  • Save kakra/7637555528a54a0c7aaca6f68338418c to your computer and use it in GitHub Desktop.
Save kakra/7637555528a54a0c7aaca6f68338418c to your computer and use it in GitHub Desktop.
systemd borgbackup units
[Unit]
Description=Daily Backup Service
[Service]
Environment=BORG_REPO=/mnt/private/backup/jupiter.sol.local.borg
Environment=BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK=yes
Environment=BORG_RELOCATED_REPO_ACCESS_IS_OK=yes
Type=oneshot
IOSchedulingClass=idle
IOSchedulingPriority=7
CPUSchedulingPolicy=batch
Nice=3
ProtectHome=read-only
ProtectSystem=full
PrivateTmp=yes
# The following line is problematic during first backup when this directory doesn't yet exist
ReadWriteDirectories=/root/.cache/borg
ReadOnlyDirectories=/mnt/btrfs-pool
WorkingDirectory=/mnt/btrfs-pool
ExecStart=/usr/bin/systemd-inhibit /usr/bin/borg create -v --stats --exclude-caches --compression zlib --exclude 'pp:gentoo/usr/portage/distfiles' --exclude 'pp:gentoo/rootfs/var/tmp' --exclude 'pp:gentoo/usr/portage/packages' ::'system@{now:%%Y%%m%%d-%%H%%M}' .
ExecStartPost=/usr/bin/borg prune -v --prefix 'system@' --keep-daily 7 --keep-weekly 5 --keep-monthly 12 --list --stats --save-space
[Unit]
Description=Daily Backup Timer
[Timer]
OnCalendar=03:00
WakeSystem=true
[Install]
WantedBy=timers.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment