From f5e570a776896f1dbf19e8090e6785304af4d81a Mon Sep 17 00:00:00 2001 From: Dave Lane Date: Mon, 14 Oct 2019 02:54:32 +0000 Subject: [PATCH] initial commit before setting up the remote --- .gitignore | 3 +++ run-restic.sh | 36 ++++++++++++++++++++++++++++++++++++ site.conf-sample | 22 ++++++++++++++++++++++ 3 files changed, 61 insertions(+) create mode 100644 .gitignore create mode 100755 run-restic.sh create mode 100644 site.conf-sample diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cea1001 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +*.conf +*~ + diff --git a/run-restic.sh b/run-restic.sh new file mode 100755 index 0000000..981358f --- /dev/null +++ b/run-restic.sh @@ -0,0 +1,36 @@ +#!/bin/bash +# +# OER Foundation backup routine: Restic +# 20190930 dave@oerfoundation.org +# +NICE='ionice -c2 nice -n19' +CMD=/usr/bin/restic +SCR=$0 +CONF=site.conf +DIR=`dirname $SCR` +SCRNAME=`basename $SCR` +if [ -f $DIR/$CONF ] ; then + source $DIR/$CONF +else + echo "You need to create a site.conf in the same directory as $SCRNAME, i.e. $DIR." + exit 1 +fi +DST=sftp:try.oerfoundation.org:/backup/make +PW=/root/restic.pw +TAG="daily" +LOG=/var/log/restic.log +ARGS="-r $DST --password-file $PW backup --tag $TAG --exclude-file=/restic.excludes --files-from /restic.files" +CLEAN="-r $DST --password-file $PW forget --tag $TAG --keep-daily 7 --keep-weekly 5 --keep-monthly 12 --keep-yearly 7" +# create a snapshot +DATE=`date` +echo "running snapshot $DATE" >> $LOG +$NICE $CMD $ARGS >> $LOG +# remove old snapshots +DATE=`date` +echo "running cleanup $DATE" >> $LOG +$NICE $CMD $CLEAN >> $LOG +# leave extra spaces +DATE=`date` +echo "done $DATE" >> $LOG +echo "" >> $LOG +echo "" >> $LOG diff --git a/site.conf-sample b/site.conf-sample new file mode 100644 index 0000000..9a95ebf --- /dev/null +++ b/site.conf-sample @@ -0,0 +1,22 @@ +# +# this contains secrets for the site. +# +# The only required field +# +# local example +# replace /backup/myserver with something appropriate for you. +DST=/backup/myserver +# +# remote example +# replace backup.server and /backup/myserver with something appropriate for you. +# note, for this to work, you will need key-based SSH authentication to the backup.server +DST=sftp:backup.server:/backup/myserver +# +# Other overrides +# +# your backup repo password +PW=/root/restic.pw +# a tag for automated backups +TAG="daily" +# the log file on this machine for logging backups +LOG=/var/log/restic.log