diff --git a/.config/setup/03-install-cron-jobs.sh b/.config/setup/03-install-cron-jobs.sh index 2ed7ab7..5b29075 100755 --- a/.config/setup/03-install-cron-jobs.sh +++ b/.config/setup/03-install-cron-jobs.sh @@ -1,3 +1,4 @@ #! /usr/bin/sh systemctl --user enable --now backup.timer +systemctl --user enable --now sync-backup.timer diff --git a/.config/systemd/user/sync-backup.service b/.config/systemd/user/sync-backup.service new file mode 100644 index 0000000..e1d77ad --- /dev/null +++ b/.config/systemd/user/sync-backup.service @@ -0,0 +1,10 @@ +[Unit] +Description=Sync local backup to the cloud +Wants=sync-backup.timer + +[Service] +WorkingDirectory=%h +ExecStart=%h/.local/bin/sync-backup service + +[Install] +WantedBy=default.target diff --git a/.config/systemd/user/sync-backup.timer b/.config/systemd/user/sync-backup.timer new file mode 100644 index 0000000..8937234 --- /dev/null +++ b/.config/systemd/user/sync-backup.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Daily backup cloud sync +Requires=sync-backup.service + +[Timer] +Unit=sync-backup.service +OnCalendar=daily + +[Install] +WantedBy=timers.target diff --git a/.local/bin/sync-backup b/.local/bin/sync-backup new file mode 100755 index 0000000..8e6574a --- /dev/null +++ b/.local/bin/sync-backup @@ -0,0 +1,9 @@ +#! /usr/bin/sh + +export BORG_REPO="/media/backup/" + +if [ "$1" = "service" ]; then + rclone sync "${BORG_REPO}" gdrive-backup:hot-repo/ +else + rclone sync --progress "${BORG_REPO}" gdrive-backup:hot-repo/ +fi