第一种方法:tar备份

[root@bogon ~]# cat bp/linux.txt 
no centos
[root@bogon ~]# tar cvf bp.tar bp    //打包bp目录
bp/
bp/bp/
bp/bp/a.txt
bp/kali.txt
bp/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.txt
bp/kali.txt
bp/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.txt
bp/kali.txt
bp/linux.txt
[root@bogon ~]# ls
anaconda-ks.cfg  bp.tar.gz  Documents  initial-setup-ks.cfg  Music            Pictures  Templates
bp               Desktop    Downloads  linux.txt             original-ks.cfg  Public    Videos
[root@bogon ~]# cat bp/linux.txt
no centos
[root@bogon ~]# echo 'bp'>bp/linux.txt
[root@bogon ~]# cat bp/linux.txt
bp
[root@bogon ~]# tar -zxvf bp.tar.gz 
bp/
bp/bp/
bp/bp/a.txt
bp/kali.txt
bp/linux.txt
[root@bogon ~]# cat bp/linux.txt     //还原
no centos
[root@bogon ~]# 

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

相关文章:

  • 2022-01-17
  • 2021-11-27
  • 2021-11-17
  • 2022-01-06
  • 2021-11-14
  • 2021-07-30
  • 2021-12-14
  • 2022-12-23
猜你喜欢
  • 2021-11-17
  • 2022-12-23
  • 2021-11-27
  • 2021-07-01
  • 2021-06-06
  • 2021-08-18
相关资源
相似解决方案