1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#!/bin/bash
#zuozhe:lijinzhu (qq:348450594)
#备份脚本
ntpdate asia.pool.ntp.org &>
/dev/null
date
=`
date
+%y%m%d`
size=`
du
-sh
/etc
`
if
[ -d
/tmp/dbback
]
then
echo
"date is: $date"
>
/tmp/dbback/bak
.txt
echo
"size is: $size"
>>
/tmp/dbback/bak
.txt
cd
/tmp/dbback
tar
-zcf etc_$
date
.
tar
.gz
/etc
bak.txt &>
/dev/null
rm
-rf
/tmp/dbback/bak
.txt
else
mkdir
/tmp/dbback
echo
"date is: $date"
>
/tmp/dbback/bak
.txt
echo
"size is: $size"
>>
/tmp/dbback/bak
.txt
cd
/tmp/dbback
tar
-zcf etc_$
date
.
tar
.gz
/etc
bak.txt &>
/dev/null
rm
-rf
/tmp/dbback/bak
.txt
fi
|
本文转自limingyu0312 51CTO博客,原文链接:http://blog.51cto.com/limingyu/1910247,如需转载请自行联系原作者