36 lines
976 B
Bash
Executable file
36 lines
976 B
Bash
Executable file
#!/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
|