Project

General

Profile

Borg backups » 75-borglocalbackupcheck.sh

Jamila Khan, 05/11/2017 12:35 PM

 
1
#!/bin/sh
2

    
3
export BORG_PASSPHRASE='PASSPHRASE'
4

    
5
#figure out the disk that is currently attached
6

    
7
#list the devices attached, output it to a file
8
ls /dev/disk/by-uuid -ah > /tmp/uuid1.txt
9

    
10
#list the devices that are local backup drives, output that to a file
11
head -n 30 /etc/backup.d/70-local.borglocal | grep device_uuid | cut -f 3 -d ' ' | sort  > /tmp/uuid2.txt
12

    
13
#set the variable disk to be the drive in common
14
disk=`comm -1 -2 /tmp/uuid1.txt /tmp/uuid2.txt`
15

    
16
OUTPUT=$((
17

    
18
#mount it
19
mount /dev/disk/by-uuid/$disk /mnt/borg_usb
20

    
21
#check it
22
borg check -v /mnt/borg_usb/borgbackup
23

    
24
#unmount the drive
25
umount /mnt/borg_usb 
26

    
27

    
28
) 2>&1)
29
if [ $? -ne 0 ]
30
then
31
warning $OUTPUT
32
fi
33

    
34
unset BORG_PASSPHRASE
(8-8/8) Go to top