-
Notifications
You must be signed in to change notification settings - Fork 1
/
backup.sh
executable file
·72 lines (38 loc) · 1.16 KB
/
backup.sh
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
67
68
69
70
71
72
#!/bin/bash
BACKUPDIR=backup
TMPDIR=.
URLS=urls.list
# URL=http://pad.constantvzw.org/p/conversations.clilley/export/txt
for URL in `cat $URLS`
do
NAME=`echo $URL | \
sed 's,^http://,,g' | \
sed 's/\./XjcuDCHX34/g' | \
sed 's,/export/txt,,g' | \
sed 's,/,835FtxcuzG,g' | \
sed 's/[^a-zA-Z0-9 ]//g' | \
sed 's,835FtxcuzG,-,g' | \
sed 's/XjcuDCHX34/\./g'`
BACKUPFILE=$BACKUPDIR/${NAME}.txt
EPDUMPFILE=${TMPDIR}/${NAME}.tmp
if [ -f $BACKUPFILE ]; then
MD5BACKUP=`md5sum $BACKUPFILE | cut -d " " -f 1`
else
MD5BACKUP=XX
touch $BACKUPFILE
git add $BACKUPFILE
fi
wget --no-check-certificate -O ${TMPDIR}/${NAME}.tmp $URL > /dev/null 2>&1
MD5EPDUMP=`md5sum $EPDUMPFILE | cut -d " " -f 1`
if [ $MD5BACKUP != $MD5EPDUMP ]; then
mv $EPDUMPFILE $BACKUPFILE
GITM="$URL backed up on "`date +%d.%m.%Y\ %H:%M:%S`
echo $GITM
git commit -m "$GITM" $BACKUPFILE
else
echo "${NAME}: Backup up-to-date"
rm $EPDUMPFILE
fi
done
exit 0;
exit 0;