summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--cron/cron.d/restic_orpheus8
-rw-r--r--scripts/sh/restic/check.sh3
-rw-r--r--scripts/sh/restic/cleanup.sh3
-rw-r--r--scripts/sh/restic/ls.sh3
-rw-r--r--scripts/sh/restic/run_extended.sh36
-rw-r--r--scripts/sh/restic/snapshots.sh3
6 files changed, 53 insertions, 3 deletions
diff --git a/cron/cron.d/restic_orpheus b/cron/cron.d/restic_orpheus
index ca1ab51..eda54ea 100644
--- a/cron/cron.d/restic_orpheus
+++ b/cron/cron.d/restic_orpheus
@@ -1,9 +1,11 @@
-# Cronjob for Restic Backup to S3
+# Cronjob for Restic Backup to Wasabi S3
# Created and last modified: 20/07/2021
# georg@lysergic.dev
MAILTO=system
SHELL=/bin/sh
-#This will make a deduplicating backup every day at 22:00 and send an email to system@lysergic.dev as well as #universe
-0 22 * * * restic /opt/restic/run.sh |& mail -s "S3 Backup - $(hostname -f) - $(date)" ircsystem
+#This will make a deduplicating (is that the right word?) backup every day at 23:00 and send an email to system@lysergic.dev as well as #universe
+0 22 * * * restic /opt/restic/run.sh |& mail -s "[S3 Backup] - $(hostname -f) - $(date)" ircsystem
+#This will remove everything except the last 30 days worth of snapshots every two days at 22:30
+0 4 */2 * * restic /opt/restic/cleanup.sh |& mail -s "[S3 Cleanup] - $(date)" ircsystem
diff --git a/scripts/sh/restic/check.sh b/scripts/sh/restic/check.sh
new file mode 100644
index 0000000..567798a
--- /dev/null
+++ b/scripts/sh/restic/check.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+. restic_env
+/usr/bin/restic check
diff --git a/scripts/sh/restic/cleanup.sh b/scripts/sh/restic/cleanup.sh
new file mode 100644
index 0000000..ccfe9c2
--- /dev/null
+++ b/scripts/sh/restic/cleanup.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+. restic_env
+/usr/bin/restic forget --group-by hosts,paths --keep-daily 90 --prune --cleanup-cache -v
diff --git a/scripts/sh/restic/ls.sh b/scripts/sh/restic/ls.sh
new file mode 100644
index 0000000..240b654
--- /dev/null
+++ b/scripts/sh/restic/ls.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+. restic_env
+/usr/bin/restic ls -l $1
diff --git a/scripts/sh/restic/run_extended.sh b/scripts/sh/restic/run_extended.sh
new file mode 100644
index 0000000..8956760
--- /dev/null
+++ b/scripts/sh/restic/run_extended.sh
@@ -0,0 +1,36 @@
+#!/bin/sh
+#/usr/bin/echo Executing Restic S3 Backup for $(hostname -f)
+#Note: This script includes a special configuration for orpheus to include Gitea dumps in the backup and hence differs from the universal scripts deployed to other machines.
+export RESTIC_REPOSITORY="s3:$S3PROTO://$S3HOST/$S3BUCKET"
+export RESTIC_PASSWORD_FILE="$LIBPASS"
+export AWS_ACCESS_KEY_ID="$S3AKI"
+export AWS_SECRET_ACCESS_KEY="$S3SAK"
+export RESTIC_CACHE_DIR="$CACHE"
+EXCLUDE=".restic.excludes"
+echo "Creating Gitea dump prior to backup ..."
+GITEA_DUMPFILE="gitea-$(date -u +%d%m%y-%H%M).tar.gz"
+sudo -u git /usr/local/bin/gitea dump -L --type tar.gz -t /var/lib/git/dump -c /etc/gitea/app.ini -C /var/lib/gitea/custom -w /var/lib/gitea -f /var/lib/git/dump/$GITEA_DUMPFILE
+echo "Created Gitea Dumpfile: $GITEA_DUMPFILE"
+echo
+echo "Storing /etc/ ..."
+/usr/bin/restic --verbose backup --exclude-file="/etc/$EXCLUDE" /etc
+echo "EXIT $?"
+echo "Storing /home/ ..."
+/usr/bin/restic --verbose backup --exclude-file="/home/$EXCLUDE" /home
+echo "EXIT $?"
+echo "Storing /mnt/gluster01/ ..."
+/usr/bin/restic --verbose backup --exclude-file="/mnt/gluster01/$EXCLUDE" /mnt/gluster01
+echo "EXIT $?"
+echo "Storing /opt/ ..."
+/usr/bin/restic --verbose backup --exclude-file="/opt/$EXCLUDE" /opt
+echo "EXIT $?"
+echo "Storing /srv/ ..."
+/usr/bin/restic --verbose backup --exclude-file="/srv/$EXCLUDE" /srv
+echo "EXIT $?"
+echo "Storing /var/ ..."
+/usr/bin/restic --verbose backup --exclude-file="/var/$EXCLUDE" /var
+echo "EXIT $?"
+echo "Removing Gitea dumpfile."
+sudo -u git /usr/bin/rm /var/lib/git/dump/$GITEA_DUMPFILE
+echo
+echo "OK"
diff --git a/scripts/sh/restic/snapshots.sh b/scripts/sh/restic/snapshots.sh
new file mode 100644
index 0000000..973598d
--- /dev/null
+++ b/scripts/sh/restic/snapshots.sh
@@ -0,0 +1,3 @@
+#!/bin/sh
+. restic_env
+/usr/bin/restic snapshots --group-by hosts