linux之数据备份

来源:互联网 发布:javmoo.net最新域名 编辑:程序博客网 时间:2024/05/24 01:20

第一种方法:tar备份

[root@bogon ~]# cat bp/linux.txt no centos[root@bogon ~]# tar cvf bp.tar bp    //打包bp目录bp/bp/bp/bp/bp/a.txtbp/kali.txtbp/linux.txt[root@bogon ~]# echo "this is centos">bp/linux.txt    //把内容修改[root@bogon ~]# cat bp/linux.txt this is centos[root@bogon ~]# tar xvf bp.tar      //还原bp/bp/bp/bp/bp/a.txtbp/kali.txtbp/linux.txt[root@bogon ~]# cat bp/linux.txt //文件内容得以还原no centos[root@bogon ~]# tar zcvf bp.tar.gz bp   //因为tar不对文件进行压缩,所以打包后的文件会很大,一般在打包的同时进行压缩bp/bp/bp/bp/bp/a.txtbp/kali.txtbp/linux.txt[root@bogon ~]# lsanaconda-ks.cfg  bp.tar.gz  Documents  initial-setup-ks.cfg  Music            Pictures  Templatesbp               Desktop    Downloads  linux.txt             original-ks.cfg  Public    Videos[root@bogon ~]# cat bp/linux.txtno centos[root@bogon ~]# echo 'bp'>bp/linux.txt[root@bogon ~]# cat bp/linux.txtbp[root@bogon ~]# tar -zxvf bp.tar.gz bp/bp/bp/bp/bp/a.txtbp/kali.txtbp/linux.txt[root@bogon ~]# cat bp/linux.txt     //还原no centos[root@bogon ~]# 

第二种方法:contab备份,我的其他博客写有使用方法了,这里不再重复