-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnapper_purge
executable file
·66 lines (52 loc) · 1.75 KB
/
snapper_purge
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
66
#!/bin/bash
source /etc/backup.conf
if test -f $CMD_DUPLICITY;
then
echo ""
OIFS=$IFS
while getopts ':p:' OPTION ; do
case "$OPTION" in
p) EXCLUDE_GREP="| grep '$OPTARG'";;
*)
EXCLUDE_GREP="| grep -v 'Snapshot'"
for i in ${EXCLUDE_LVS[@]}; do
EXCLUDE_GREP="$EXCLUDE_GREP | grep -v '$i'"
done
;;
esac
done
lvscantext=`eval /sbin/lvscan $EXCLUDE_GREP`
datum=`cat /srv/storage/backup/lastbackup.txt`
datumzeit="$(date +%Y-%m-%d-%H-%M-%S)"
PROBLEM="false"
IFS=$'\n'
i=0
export FTP_PASSWORD=$FTP_PASSWORD
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 "Purge $LVname:"
echo "-------------------------------------------------"
echo "=> ${SAVETIME} alte Images vom FTP-Server entfernen"
$CMD_DUPLICITY remove-older-than 0 --force ftp://${FTP_USER}@${FTP_SERVER}/vm-images/${LVname}
echo "-------------------------------------------------"
fi
done
unset FTP_PASSWORD
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