Sooner or later you will find that you're unable to do a backup or some backup checking because the repository is locked. This script will unlock the repository and is called 'restic-unlock'. Its not run from a cronjob, just from your terminal whenever its needed.

But BEWARE of killing a running restic backup unnecessarily.

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

#: Title            : restic-unlock
#: 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/>.

####################################################
# 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-unlock.txt"
###########

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

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

/usr/local/bin/restic -r $RESTIC_REPOSITORY -p ~/bin/restinpeace.txt unlock

if [ "$?" -ne 0 ]; then
  notify-send "Unable to finish restic unlock"
  exit 1
else

  notify-send "Finished restic unlock"

  du -sh /mnt/backc/restic-back

echo 'Sending Unlock report : Unlock of restic completed', $(date -R) 'logged to' $logfile
echo '####################################'

fi


Comments

comments powered by Disqus