From ef74f5534d03e15f96b9b5e022a2737bdd9c1b59 Mon Sep 17 00:00:00 2001 From: james Date: Tue, 19 Nov 2024 12:12:42 -0500 Subject: [PATCH] Initial commit --- backup.sh | 9 +++++++++ excludes.txt | 11 +++++++++++ passwd | 1 + restic.service | 7 +++++++ restic.timer | 10 ++++++++++ restic_env.sh | 6 ++++++ 6 files changed, 44 insertions(+) create mode 100755 backup.sh create mode 100644 excludes.txt create mode 100644 passwd create mode 100644 restic.service create mode 100644 restic.timer create mode 100755 restic_env.sh diff --git a/backup.sh b/backup.sh new file mode 100755 index 0000000..70bd721 --- /dev/null +++ b/backup.sh @@ -0,0 +1,9 @@ +#!/bin/bash +exec &>>/var/log/restic.log +source /etc/restic/restic_env.sh +cd ${BACKUP_ROOT} +date +"%h %e %T $HOSTNAME restic $$[$BASHPID]: Starting backup" +restic backup --exclude-file /etc/restic/excludes.txt . +date +"%h %e %T $HOSTNAME restic $$[$BASHPID]: Pruning old files" +restic prune >> /var/log/restic.log +date +"%h %e %T $HOSTNAME restic $$[$BASHPID]: Backup complete" diff --git a/excludes.txt b/excludes.txt new file mode 100644 index 0000000..4873e12 --- /dev/null +++ b/excludes.txt @@ -0,0 +1,11 @@ +.* +!.profile.d +!.qlcplus +!.ssh +!.github +.git +*.bak +Music +*.old +BL-* +Downloads diff --git a/passwd b/passwd new file mode 100644 index 0000000..a147512 --- /dev/null +++ b/passwd @@ -0,0 +1 @@ +PutASuperSecurePasswordHere diff --git a/restic.service b/restic.service new file mode 100644 index 0000000..203f51b --- /dev/null +++ b/restic.service @@ -0,0 +1,7 @@ +[Unit] +Description=Restic Backup + +[Service] +Type=exec +Restart=no +ExecStart=/etc/restic/backup.sh diff --git a/restic.timer b/restic.timer new file mode 100644 index 0000000..a4672f2 --- /dev/null +++ b/restic.timer @@ -0,0 +1,10 @@ +[Unit] +Description=Run backup weekly + +[Timer] +OnCalendar=weekly +Persistent=true +Unit=restic.service + +[Install] +WantedBy=timers.target diff --git a/restic_env.sh b/restic_env.sh new file mode 100755 index 0000000..8803c38 --- /dev/null +++ b/restic_env.sh @@ -0,0 +1,6 @@ +export HOME=/root/ +export AWS_ACCESS_KEY_ID= +export AWS_SECRET_ACCESS_KEY= +export RESTIC_REPOSITORY="s3:s3.us-west-000.backblazeb2.com/" +export RESTIC_PASSWORD_FILE=/etc/restic/passwd +export BACKUP_ROOT=/home/james