文件的压缩与解压
1.常见格式
.tar .tar.gz .tgz .gz .Z .bz2
2.命令汇总
compress 古老的压缩命令
gzip
BZIP2
tar
3.
1).compress uncompress
2).gzip -cdtv# file
压缩后源文件将丢失
gzip -v a.txt
zcat a.txt.gz
解压
gzip -d a.txt.gz
要想保留源文件 使用 -c 并重定向
3).bzip2
bzip2 相比 gzip 多了一个 z 参数,代表压缩
4).tar
文件夹打包,还是 tar 比较强大
tar -cvf
-t 显示目录结构吧
-jz 压缩
-C 特定目录解压锁
-p 保留权限属性
-P 可包含根目录
–exclude 不包含
–newer-time=’2017-01-01’
tar -tf en.gz
tar -xvf en.gz ./haha/o.txt
find /etc -newer /etc/passwd
tar -czvf ~/test.gz –newer-mtime=”2017/01/09” /etc/*
5).dump
备份文件系统或者目录
df -h
备份时间
dump -S /dev/sdc1
备份等级,完全备份
dump -0u /dev/sdc1
cat /etc/dumpdates 备份记录
备份记录
dump -W
dd if=/dev/zero of=/boot/test.file bs=1M count=10
dump -0u -f /root/ha.2 /boot
对与非文件系统的目录
dump -0j -f /root/hah /etc
6) restore
restore -t -f dumpfile -h dump归档查看
restore -C -f dumpfile -D 比较
restore -i -f dumpfile 互动模式
restore -r -f dumpfile 还原整个文件系统