一、打包与解压

(一)、打包压缩

[root@linux ~]# tar -czf etc1.tar.gz /etc                            //-z 调用gzip
[root@linux ~]# tar -cjf etc2.tar.bz2 /etc //-j 调用bzip2
[root@linux ~]# tar -cJf etc3.tar.xz /etc //-J 调用xz
[root@linux ~]# ll -h etc*
-rw-r--r--. root root 8.7M 3月 : etc1.tar.gz
-rw-r--r--. root root 7.5M 3月 : etc2.tar.bz2
-rw-r--r--. root root 4.8M 3月 : etc3.tar.xz

(二)、解压、解包

[root@linux ~]# tar -tf sys.tar.xz
[root@linux ~]# tar -xzvf etc1.tar.gz
[root@linux ~]# tar -xvf etc1.tar.gz //无需指定解压工具,tar会自动判断
[root@linux ~]# tar -xvf etc2.tar.bz2 -C /tmp //-C重定向到//tmp目录
[root@linux ~]# tar xf etc3.tar.xz

(三)、解压ZIP

[root@linux ~]# unzip xxx.zip

二、案例

(一)、案例1:mysql物理备份及恢复

[root@localhost ~]# tar -cJf /backup/mysql.tar.xz /var/lib/mysql
[root@localhost ~]# tar -xf /backup/mysql.tar.xz -C /

(二)、  mysql物理备份及恢复

[root@localhost ~]# cd /var/lib/mysql
[root@localhost mysql]# tar -cJf /backup/mysql.tar.xz *
[root@localhost mysql]# tar -xf /backup/mysql.tar.xz -C /var/lib/mysql

(三)案例3:host A /etc (海量小文件)

[root@localhost ~]# tar -czf - /etc |tar -xzf - -C /tmp

(四)、案例4:host A /etc(海量小文件)

常规方法:
[root@localhost ~]# scp -r /etc 172.16.20.21:/tmp

建议方法:

==host B 监听端口==
[root@hostb ~]# systemctl stop firewalld.service
[root@hostb ~]# nc -l |tar -xzf - -C /tmp ==host A ==
[root@localhost ~]# tar -czf - /etc | nc 172.16.20.21
tar: Removing leading `/' from member names

最新文章

  1. [Git] Git 常用技巧
  2. 打开FTP服务器上的文件夹时发生错误,请检查是否有权限访问该文件夹
  3. 【Bootstrap3.0建站笔记三】AspNetPager分页,每一列都可排序
  4. SqlLite ---.net连接数据库
  5. js冒泡事件示例
  6. Android 2014年1月22日
  7. PHP之路——微信公众号授权获取用户信息
  8. silverlight .net后台 设置visifire控件图表样式 属性说明
  9. 处理json中的异常字符
  10. matlab实现可调节占空比的方波
  11. yii2 源码分析 model类分析 (五)
  12. 014_zk路径过滤分析
  13. css 实现文字提示说明、文字绕图效果
  14. 目标指定法——S.M.A.R.T.
  15. linux批量替换文件内容3种方法(perl,sed,shell)
  16. 批量插入bulkcopy
  17. BUAA 111 圆有点挤
  18. laravel注册行为的方法和逻辑
  19. jstat 使用日志
  20. progressDialog和子线程模拟显示拷贝进度

热门文章

  1. Programming In Lua 第二章
  2. 17 | 精益求精:聊聊提高GUI测试稳定性的关键技术
  3. java 中的一些运算符问题
  4. 线性表的顺序存储C++代码实现
  5. 数字IC前后端设计中的时序收敛(一)前言
  6. Drools规则引擎-memberOf操作
  7. CDQZ集训DAY9 日记
  8. CAD2014学习笔记-常用绘图命令和工具
  9. Java的Hook线程及捕获线程执行异常
  10. kali linux 常用文件与指令路径