I'm now including my forget
command in with my restic-check
script because if its included in resticup
then when restic-check
is run it has about 30+ index files to delete, so its actually more efficent to run forget just once in a 24-hour period and then also run the prune
command with it, like this -
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 | #!/bin/bash
#: Title : restic-check
#: Date : 19 August 2017, 11 September 2017
#: Author : Sharon Kimble
#: Version : 2.0
#: Description : script to help in running restic checkup for backups
#: License : GNU GPL 3.0 or later
# Copyright (C) 2017 Sharon Kimble <[email protected]>
# Author: Sharon Kimble <[email protected]>
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
####################################################
# How to use.
# Change the lines in the '#Variables' section to fit your situation and your
# file tree. And save it in ~/bin/resticup, and then run 'chmod +x ~/bin/resticup'
# to make it executable.
# Then put an entry for it in your crontab, this is mine -
# 00 01 * * * DISPLAY=:0 /home/boudiccas/bin/restic-check
#######################
# Variables
RESTIC_REPOSITORY="/mnt/backc/restic-back"
# Setting this, so you won't be asked for your repository passphrase/password
LOGFILE="/home/boudiccas/logs/backup-restic-check.txt"
EXEMPTIONS="--keep-hourly 4 --keep-daily 31 --keep-weekly 5 --keep-monthly 13 --keep-yearly 10"
###########
exec > >(tee -a $LOGFILE) 2>&1
/usr/bin/notify-send "Starting restic check ..."
/usr/local/bin/restic -r $RESTIC_REPOSITORY -p ~/bin/restinpeace.txt forget $EXEMPTIONS --prune
/usr/local/bin/restic -r $RESTIC_REPOSITORY -p ~/bin/restinpeace.txt rebuild-index
/usr/local/bin/restic -r $RESTIC_REPOSITORY -p ~/bin/restinpeace.txt check
if [ "$?" -ne 0 ]; then
notify-send "Unable to finish restic check"
exit 1
else
notify-send "Finished restic check"
du -sh /mnt/backc/restic-back
echo 'Sending Check report : Check of restic completed', $(date -R) 'logged to' $LOGFILE
echo '####################################'
fi
|
Here is an explanation why I have --keep-daily 31
as part of my EXEMPTIONS
. With just --keep-daily 7
in place, restic was forgetting some days, whereas I was wanting to keep a consecutive list of days backed up. So after quite a detailed conversation on IRC with 'fd0' 31 days is what we've come up with.
So here is my amended version 2 of resticup
-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | #!/bin/bash
#: Title : resticup
#: Date : 17 August 2017, 11 September 2017
#: Author : Sharon Kimble
#: Version : 2.0
#: Description : script to help in running restic for backups
#: License : GNU GPL 3.0 or later
# Copyright (C) 2017 Sharon Kimble <[email protected]>
# Author: Sharon Kimble <[email protected]>
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 3
# of the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
####################################################
# How to use.
# Change the lines in the '#Variables' section to fit your situation and your file tree. And save
# it in ~/bin/resticup, and then run 'chmod +x ~/bin/resticup' to make it executable.
# Then put an entry for it in your crontab, this is mine -
# 00 */4 * * * DISPLAY=:0 /home/boudiccas/bin/resticup #backup /home and let it run every 4
# hours for backups.
#######################
# Variables
RESTIC_REPOSITORY="/mnt/backc/restic-back"
LOGFILE="/home/boudiccas/logs/backup-restic.txt"
BACKUP_DIRS="/home/boudiccas /var/www"
EXCLUDED_DIRS="/home/*/.cache ~/.gvfs ~/.config/freeter/Partitions/freeter/Cache/"
###########
# Log all stdout+stderr
exec > >(tee -a $LOGFILE) 2>&1
/usr/bin/notify-send "Starting main backup..."
/usr/local/bin/restic -r $RESTIC_REPOSITORY -p ~/bin/restinpeace.txt backup $BACKUP_DIRS --exclude $EXCLUDED_DIRS
/usr/local/bin/restic -r $RESTIC_REPOSITORY -p ~/bin/restinpeace.txt snapshots
if [ "$?" -ne 0 ]; then
notify-send "Unable to finish main backup"
exit 1
else
notify-send "Finished main backup"
du -sh /mnt/backc/restic-back
echo 'Sending Backup report : Backup of restic completed', $(date -R) 'logged to' $LOGFILE
echo '####################################'
fi
|
Comments
comments powered by Disqus