linux之数据备份

第一种方法: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备份,我的其他博客写有使用方法了,这里不再重复

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值