-
Notifications
You must be signed in to change notification settings - Fork 0
/
snapper_remove
executable file
·53 lines (41 loc) · 1.64 KB
/
snapper_remove
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
#!/bin/bash
source /etc/backup.conf
if test -f $CMD_DUPLICITY;
then
echo ""
OIFS=$IFS
lvscantext=`lvscan`
datum=`cat /srv/storage/backup/lastbackup.txt`
datumzeit="$(date +%Y-%m-%d-%H-%M-%S)"
PROBLEM="false"
IFS=$'\n'
i=0
echo "-------------------------------------------------"
echo "-------------------------------------------------"
echo "----- BACKUP-JOB $datumzeit ------------"
echo "-------------------------------------------------"
for zeile in $lvscantext
do
i=$[$i+1]
echo $zeile
ACTIVE=`echo $zeile | awk -v FS=" " '{print $1}'`
LV=`echo $zeile | awk -v FS="'" '{print $2}'`
LVname=`echo $LV | sed "s:/:_:g" | sed "s:_::"`
LVname=`echo $LV | awk -v FS="/" '{print $NF}'`
VGname=`echo $LV | sed "s:/${LVname}::"`
if [ $ACTIVE == "ACTIVE" ];
then
echo "Backup $LVname:"
echo "-------------------------------------------------"
echo "=> ${SAVETIME} alte Images vom FTP-Server entfernen"
$CMD_DUPLICITY remove-older-than ${SAVETIME} --force ftp://${FTP_USER}@${FTP_SERVER}/vm-images/${LVname}
echo "=> alle Inc-Backups löschen, welche nicht zur aktuellen Chain gehören"
$CMD_DUPLICITY remove-all-inc-of-but-n-full 1 --force ftp://${FTP_USER}@${FTP_SERVER}/vm-images/${LVname}
echo "-------------------------------------------------"
fi
done
IFS=$OIFS
else
echo "duplicity was not found. please correct path-"
echo "duplicity was not found. please correct path-" | mail -s "duplicity not found @ `hostname`!" $KONTAKTADRESSE
fi