Its a very good idea to regularly check the integrity of your restic backups to hopefully find any problems before you have to use it to restore some files from backup. So this is my script called 'restic-check' which will run at 0100 from a cronjob. I know it works as I've tried it out before setting the cronjob.

 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
#!/bin/bash

#: Title            : restic-check
#: Date             : 19 August 2017
#: Author           : Sharon Kimble
#: Version          : 1.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"
###########

exec > >(tee -a $logfile) 2>&1

/usr/bin/notify-send "Starting restic check ..."

/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


Comments

comments powered by Disqus