由此我们可以很方便的通过日期寻找指定时间的备份文件
接下来对该备份文件进行解压:
[root@wzp 16]# pwd
/tmp/05/16
[root@wzp 16]# tar zxvf archive1339.tar.gz
/root/etc/httpd/
tar: Removing leading `/' from member names
/root/etc/httpd/logs
/root/etc/httpd/conf/
/root/etc/httpd/conf/httpd.conf
/root/etc/httpd/conf/magic
/root/etc/httpd/archive1333.tar.gz
/root/etc/httpd/run
/root/etc/httpd/conf.d/
/root/etc/httpd/conf.d/README
/root/etc/httpd/conf.d/proxy_ajp.conf
/root/etc/httpd/conf.d/welcome.conf
/root/etc/httpd/conf.d/Python.conf
/root/etc/httpd/conf.d/php.conf
/root/etc/httpd/conf.d/perl.conf
/root/etc/httpd/conf.d/manual.conf
/root/etc/httpd/conf.d/squid.conf
/root/etc/httpd/conf.d/webalizer.conf
/root/etc/httpd/conf.d/ssl.conf
/root/etc/httpd/modules
这里你会发现出现了一行报错信息:
tar: Removing leading `/' from member names
说是移除了/,不过之所以这么做主要是为了安全起见(理解不了就百度)
因为对于备份文件需要解压回来使用的时候,会放置于原来的位置而覆盖原目录下所有内容。通过拿掉根目
录使得压缩后采用了相对路径,避免旧的文件覆盖的新的文件
[root@wzp 16]# ll
total 52
-rw-r--r-- 1 root root 47805 May 16 13:39 archive1339.tar.gz
drwxr-xr-x 3 root root 4096 May 16 13:40 root
从这里我们也看到了我们备份的原目录是/root/etc/httpd
解压后被去掉了第一个/就变成了root
[root@wzp 16]# tree root/
root/
`-- etc
`-- httpd
|-- archive1333.tar.gz
|-- conf
| |-- httpd.conf
| `-- magic
|-- conf.d
| |-- README
| |-- manual.conf
| |-- perl.conf
| |-- php.conf
| |-- proxy_ajp.conf
| |-- python.conf
| |-- squid.conf
| |-- ssl.conf
| |-- webalizer.conf
| `-- welcome.conf
|-- logs -> ../../var/log/httpd
|-- modules -> ../../usr/lib/httpd/modules
`-- run -> ../../var/run
4 directories, 16 files
[root@wzp 16]# du -s root/etc/httpd/
112 root/etc/httpd/
[root@wzp 16]# du -s /root/etc/httpd/
112 /root/etc/httpd/
原文件和解压后的文件大小内容完全一致
最后就是通过cron实现该脚本的定期运行实现指定的数据的backup了!!