zoukankan      html  css  js  c++  java
  • 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备份,我的其他博客写有使用方法了,这里不再重复

  • 相关阅读:
    join
    PS1-4
    tftp + bras
    awk调用shell
    curl
    ssh
    查看cp进度,使用watch
    tftp
    scp 链接文件的问题 + tar
    mysql必知必会(三、使用mysql)
  • 原文地址:https://www.cnblogs.com/biaopei/p/7730568.html
Copyright © 2011-2022 走看看