-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbackupfiles
executable file
·72 lines (57 loc) · 2.57 KB
/
backupfiles
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/sh
fileroot='ROOT DRUPAL DIRECTORY'
backuproot='BACKUP DIRECTORY'
siteid='UNIQUE SITE ID'
nondrupal=0 # set to 1 if the site root should be backed up instead
daily=0 # set to 1 if the script should be run daily instead of MWF
dow=`/bin/date +%w`
dom=`/bin/date +%d`
if [ $dow -eq 3 -o $dow -eq 5 ]
then
daily=1
fi
if [ $nondrupal -eq 0 ]
then
if [ $daily -eq 1 -a $dow -ne 1 ]
then
tar -C $fileroot -czf $backuproot/$siteid-sites-default-files-wf`/bin/date +%Y%m%d`.tar.gz sites/default/files
chmod 400 $backuproot/$siteid-sites-default-files-wf`/bin/date +%Y%m%d`.tar.gz
tar -C $fileroot -czf $backuproot/$siteid-sites-all-wf`/bin/date +%Y%m%d`.tar.gz sites/all
chmod 400 $backuproot/$siteid-sites-all-wf`/bin/date +%Y%m%d`.tar.gz
else
if [ $dow -eq 1 ]
then
tar -C $fileroot -czf $backuproot/$siteid-sites-default-files-weekly`/bin/date +%Y%m%d`.tar.gz sites/default/files
chmod 400 $backuproot/$siteid-sites-default-files-weekly`/bin/date +%Y%m%d`.tar.gz
tar -C $fileroot -czf $backuproot/$siteid-sites-all-weekly`/bin/date +%Y%m%d`.tar.gz sites/all
chmod 400 $backuproot/$siteid-sites-all-weekly`/bin/date +%Y%m%d`.tar.gz
rm -f $backuproot/$siteid-sites-default-files-wf*
rm -f $backuproot/$siteid-sites-all-wf*
fi
fi
if [ $dom = '01' ]
then
mv $backuproot/$siteid-sites-default-files-weekly`/bin/date --date='last monday' +%Y%m%d`.tar.gz $backuproot/$siteid-sites-default-files-monthly`/bin/date --date='last monday' +%Y%m%d`.tar.gz
mv $backuproot/$siteid-sites-all-weekly`/bin/date --date='last monday' +%Y%m%d`.tar.gz $backuproot/$siteid-sites-all-monthly`/bin/date --date='last monday' +%Y%m%d`.tar.gz
rm -f $backuproot/$siteid-sites-default-files-weekly*
rm -f $backuproot/$siteid-sites-all-weekly*
fi
else
if [ $daily -eq 1 -a $dow -ne 1 ]
then
tar -C $fileroot -czf $backuproot/$siteid-allfiles-wf`/bin/date +%Y%m%d`.tar.gz .
chmod 400 $backuproot/$siteid-allfiles-wf`/bin/date +%Y%m%d`.tar.gz
else
if [ $dow -eq 1 ]
then
tar -C $fileroot -czf $backuproot/$siteid-allfiles-weekly`/bin/date +%Y%m%d`.tar.gz .
chmod 400 $backuproot/$siteid-allfiles-weekly`/bin/date +%Y%m%d`.tar.gz
rm -f $backuproot/$siteid-allfiles-wf*
fi
fi
if [ $dom = '01' ]
then
mv $backuproot/$siteid-allfiles-weekly`/bin/date --date='last monday' +%Y%m%d`.tar.gz $backuproot/$siteid-allfiles-monthly`/bin/date --date='last monday' +%Y%m%d`.tar.gz
rm -f $backuproot/$siteid-allfiles-weekly*
fi
fi