每隔2 個小時將/etc/services 文件打包備份到/tmp 下(最好每次備份成不同的備份包)
第一個裏程碑 測試命令 把文件/etc/services壓縮到/tmp
[[email protected] ~]# cd / && tar zcf /tmp/etc.tar.gzetc/services
[[email protected] /]# ls -l /tmp/
total 404
w-r--r--. 1 root root 127314Aug 9 18:16 etc.tar.gz
[[email protected] /]# cd / && tar zcf /tmp/etc-$(date+%F_%H).tar.gz etc/services
[[email protected] /]# ls -lrt /tmp/
total 532
-rw-------. 1 root root 439Aug 9 11:42 crontab.iCpuPc
-rw-r--r--. 1 root root 127314 Aug 9 18:16 etc.tar.gz
-rw-r--r--. 1 root root127314 Aug 9 18:18etc-2017-08-09_18.tar.gz
vim/server/scripts/etc-bak.sh
cd / && tar zcf /tmp/etc-$(date +%F_%H).tar.gz etc/services
[[email protected] /]# /bin/sh /server/scripts/etc-bak.sh
[[email protected] /]# /bin/sh /server/scripts/etc-bak.sh>/dev/null 2>&1
[[email protected] /]# ls -lrt /tmp/
total 532
-rw-r--r--. 1 root root 127314 Aug 9 18:23 etc-2017-08-09_18.tar.gz
[[email protected] /]# ls -lrt /tmp/
total 532
-rw-r--r--. 1 root root 127314 Aug 9 18:24 etc-2017-08-09_18.tar.gz
#bak /etc/serves
00 */2 * * * /bin/sh /server/scripts/etc-bak.sh >/dev/null2>&1
每隔2 個小時將/etc/services 文件打包備份到/tmp 下(最好每次備份成不同的備份包)