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
|
#!/bin/bash
if
ls
/backup
|
grep
$(
date
+%F) &>
/dev/null
then
echo
"today is already backup"
exit
1
else
if
ls
/ |
grep
backup &>
/dev/null
then
if
[ -f
/backup
]
then
mv
/backup
/$(
date
+%T) &>
/dev/null
echo
"changename backup to $(date +%T)"
mkdir
/backup
&>
/dev/null
cp
-r
/etc
/backup/
$(
date
+%F)
echo
"$(date +%F) backup success"
echo
"$(date +%F) backup success"
| mail -s
"$(date +%F) backup success"
root
else
if
[ -d
/backup
]
then
echo
"backup is a dirctory"
cp
-r
/etc
/backup/
$(
date
+%F)
echo
"$(date +%F) backup success"
echo
"$(date +%F) backup success"
| mail -s
"$(date +%F) backup success"
root
fi
fi
else
mkdir
/backup
&>
/dev/null
cp
-r
/etc
/backup/
$(
date
+%F)
echo
"$(date +%F) backup success"
echo
"$(date +%F) backup success"
| mail -s
"$(date +%F) backup success"
root
fi
fi
|
本文转自 chomperwu 51CTO博客,原文链接:http://blog.51cto.com/chomper/1683315,如需转载请自行联系原作者