Sync the backup to Google Drive every day

This commit is contained in:
Ohad Livne 2025-06-04 22:47:05 +03:00
parent 2046329111
commit e32fde2ddb
Signed by: libohad-dev
GPG key ID: 34FDC68B51191A4D
4 changed files with 30 additions and 0 deletions

View file

@ -1,3 +1,4 @@
#! /usr/bin/sh #! /usr/bin/sh
systemctl --user enable --now backup.timer systemctl --user enable --now backup.timer
systemctl --user enable --now sync-backup.timer

View file

@ -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

View file

@ -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

9
.local/bin/sync-backup Executable file
View file

@ -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