学习笔记一:压缩
2015年2月5日
上午 10:23
压缩命令
压缩文件的扩展名大多是*.tar、*.tar.gz、*.tgz、*.gz、*.Z、*.bz2
常见的压缩命令gzip与bzip2,其中bzip2压缩比gzip要好
tar可以用来进行文件打包,并可支持gzip和bzip2的压缩
压缩 tar -jvc -f  filename.tar.bz2 /directory
查询 tar -jtv -f  filename.tar.bz2
解压 tar -jxv -f filename.tar.bz2 -C /puorose/directory
Dump 命令可备份文件系统或单一目录
Dump 的备份若针对文件系统时,可进行0~9的level差异备份。其中level为0为完整备份
restore命令可以还原被dump构建的备份文件
要新建光盘刻录数据时,可通过mkisofs命令来构建
可通过cdrecord来写入CD或DVD刻录机
dd可备份完整的分区或磁盘,因为dd可读取硬盘的扇区表面数据
cpio为相当优秀的备份命令,不过必须要搭配类似find命令来读入预备份文件
测试演练
gzip与bzip2压缩
 
tar打包
使用gzip压缩格式并且排除log和bz压缩档
[oracle@xitest01 schema]$  tar -zcv -f schema_tar_test.tar.gz --exclude=/u03/schema/*.log --exclude=/u03/schema/*.bz   /u03/schema
使用bzip2压缩格式并且排除log和gz压缩档
[oracle@xitest01 schema]$  tar -jcv -f schema_tar_test.tar.bz2 --exclude=/u03/schema/*.log --exclude=/u03/schema/*.gz   /u03/schema
查看两者压缩比例
[oracle@xitest01 schema]$ du -sh schema_tar_test.tar.*
160K    schema_tar_test.tar.bz2
260K    schema_tar_test.tar.gz
dump备份文件系统
模拟一个文件盘符
[root@xitest01 u04]# dd if=/dev/zero of=/u04/loop_mount bs=1M count=1024
1024+0 records in
1024+0 records out
1073741824 bytes (1.1 GB) copied, 8.35942 seconds, 128 MB/s
[root@xitest01 u04]#  mkfs.ext3 /u04/loop_mount
[root@xitest01 u04]# mount -o loop  /u04/loop_mount /u04/mount_loop
[root@xitest01 u04]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/sda2             9.7G  5.4G  3.9G  59% /
/dev/sda6              31G  1.9G   28G   7% /u02
/dev/sda5              30G   21G  7.1G  75% /u01
/dev/sda1             190M   23M  158M  13% /boot
tmpfs                1005M     0 1005M   0% /dev/shm
/dev/sdb              504G  263G  216G  55% /u03
/dev/sdc1             504G  312G  167G  66% /u04
/u04/loop_mount      1008M   34M  924M   4% /u04/mount_loop
创建dump备份目录
[root@xitest01 u04]# mkdir backup
[root@xitest01 u04]#  dump -0 -j -f /u04/backup/dump.bak /u04/loop_mount
 DUMP: Dumping /dev/sdc1 (/u04 (dir /loop_mount)) to /u04/backup/dump.bak
  DUMP: Label: none
  DUMP: Writing 10 Kilobyte records
  DUMP: Compressing output at compression level 2 (bzlib)
  DUMP: mapping (Pass I) [regular files]
  DUMP: mapping (Pass II) [directories]
  DUMP: estimated 1067027 blocks.
  DUMP: Volume 1 started with block 1 at: Thu Feb  5 10:08:25 2015
  DUMP: dumping (Pass III) [directories]
  DUMP: dumping (Pass IV) [regular files]
  DUMP: Closing /u04/backup/dump.bak
  DUMP: Volume 1 completed at: Thu Feb  5 10:09:01 2015
  DUMP: Volume 1 took 0:00:36
  DUMP: Volume 1 transfer rate: 156 kB/s
  DUMP: Volume 1 1067020kB uncompressed, 5627kB compressed, 189.626:1
  DUMP: 1067020 blocks (1042.01MB) on 1 volume(s)
  DUMP: finished in 36 seconds, throughput 29639 kBytes/sec
  DUMP: Date of this level 0 dump: Thu Feb  5 10:08:25 2015
  DUMP: Date this dump completed:  Thu Feb  5 10:09:01 2015
  DUMP: Average transfer rate: 156 kB/s
  DUMP: Wrote 1067020kB uncompressed, 5627kB compressed, 189.626:1
  DUMP: DUMP IS DONE
[root@xitest01 u04]# ls -l /u04/backup/
total 5640
-rw-r--r-- 1 root root 5762814 Feb  5 10:09 dump.bak
[root@xitest01 u04]# du -sh /u04/backup/
5.6M    /u04/backup/
测试加入文件至目录
[root@xitest01 u04]# cp ogg.tar.gz /u04/mount_loop/
[root@xitest01 u04]# du -sh /u04/mount_loop/
503M    /u04/mount_loop/
[root@xitest01 u04]# dump -1 -j -f /u04/backup/dump.bak /u04/loop_mount
DUMP: Only level 0 dumps are allowed on a subdirectory (不是单一文件系统)
  DUMP: The ENTIRE dump is aborted.
备份boot盘符测试
[root@xitest01 u04]# dump -0 -j -f /u04/backup/dump_boot.bak  /dev/sda1
[root@xitest01 u04]# dump -1 -j -f /u04/backup/dump_boo01.bak /dev/sda1
 DUMP: WARNING: There is no inferior level dump on this filesystem
  DUMP: WARNING: Assuming a level 0 dump by default (boot目录也没差异备份吗?)
[root@xitest01 u04]# cd /u04/backup/
[root@xitest01 backup]# ls
dump.bak  dump_boo01.bak  dump_boot.bak
[root@xitest01 backup]# du -sh *
5.6M    dump.bak
16M     dump_boo01.bak
16M     dump_boot.bak
 
 

Database
Ip
Gzip
 
Bzip2
 
xxxxx
xxx.xxx.xxx.xxx
2015/3/22 10:22:00 ~2015/3/23 01:5600 3小時
16GB
2015/03/25 09:05~2015/03/26 00:56 16小時
9.2GB
 
 
 
 
 
 
 
 
 

(Linux学习笔记一:压缩)[20180209]的更多相关文章

  1. linux 学习笔记 显示压缩文件 gong.zip 的文件内容

    #zip -v gong zip zip info: xxx >删除压缩文件中俄smart.txt 文件 #zip -d gong.zip smart.txt deleting:smart.tx ...

  2. Linux 学习笔记 5 文件的下载、压缩、解压、初步认识yum

    写在前面 上节我们通过简单的几组命令,已经完全的实现了文件的移动.删除.更名.以及复制,我们最常用的基本玩法,本节将带着大家学习压缩.解压的相关步骤. Linux 学习笔记 4 创建.复制.移动.文件 ...

  3. Linux 学习笔记

    Linux学习笔记 请切换web视图查看,表格比较大,方法:视图>>web板式视图 博客园不能粘贴图片吗 http://wenku.baidu.com/view/bda1c3067fd53 ...

  4. Linux学习笔记-林耐斯Notes-Linux就该这么学

    Linux学习笔记... 参考的优秀Linux网站: http://www.w3cschool.cn/linux/ http://www.linuxeye.com/ http://linux.vbir ...

  5. deepin linux学习笔记

    目录 deepin linux学习笔记 前言 linux常用命令 ls 显示文件夹内容 cd 切换当前目录 pwd 查看当前工作目录 mkdir 新建文件夹 rm 删除文件或文件夹 mv 移动文件 c ...

  6. Linux 学习笔记之超详细基础linux命令 Part 13

    Linux学习笔记之超详细基础linux命令 by:授客 QQ:1033553122 ---------------------------------接Part 12---------------- ...

  7. Linux 学习笔记之超详细基础linux命令 Part 11

    Linux学习笔记之超详细基础linux命令 by:授客 QQ:1033553122 ---------------------------------接Part 10---------------- ...

  8. Linux 学习笔记之超详细基础linux命令 Part 10

    Linux学习笔记之超详细基础linux命令 by:授客 QQ:1033553122 ---------------------------------接Part 9----------------- ...

  9. 91 Testing Linux学习笔记

    91 Testing Linux学习笔记... 学习地址:91Testing 的Linux教程=====================学习网址:http://www.91testing.net/ar ...

随机推荐

  1. 如何删除EF4.0以上的版本

    通过VS2010的Package Manager Console安装的EF版本,会在项目根目录的packages目录中生成一个EntityFramework.4.3.0目录,安装什么版本就是什么版本的 ...

  2. VC++ 6.0如何创建与调用动态链接库

    原文:http://blog.csdn.net/wanghaihao_1/article/details/51098451 1.静态链接库与动态链接库区别: 静态链接库:lib中的指令被直接包含在最终 ...

  3. Android ListView复制、删除的实现

    适配器MyAdapter: package com.zihao.adapter; import java.util.List; import com.zihao.popdemo.R; import c ...

  4. Windows ->> Windows下一代文件系统 -- Resilient file system(ReFS)

    Comming soon!!! 参考文献: Building the next generation file system for Windows: ReFS ReFS: What you need ...

  5. Microsoft Office ->> 完整卸载Office 2007

    今天用GHOST安装了Windows 8.1,结果发现预装了Office 2007,而且这个GHOST系统的Office 2007还不是很正规的安装手法安装的.它没有在注册表中注册.在打开控制面板后发 ...

  6. MongoDB安装步骤

    安装C:\Users\Administrator>d:\mongo\bin\mongod -dbpath=D:\ND.Monodb\ND.Monodb.db -logpath=D:\ND.Mon ...

  7. C#图解教程读书笔记(第6章 类进阶)

    类成员声明语句由下列部分组成:核心声明.一组可选的修饰符和一组可选的特性(attribute). [特性] [修饰符] 核心声明 修饰符: 如果有修饰符,必须放在核心声明之前. 如果有多个修饰符,要有 ...

  8. Windows Server 2008 安装wampserver失败的总结

    1.最好选择2.4以下版本. 2.如果报确实MSVCR100.dll的错误,需要下载运行环境包(参考博客)

  9. JSFUtils

    import java.util.Iterator; import java.util.Locale; import java.util.Map; import java.util.MissingRe ...

  10. 「Newcoder练习赛40D」小A与最大子段和

    题目 挺好的一道题 我们考虑把\(i\)作为选取的最大子段的结束位置,我们如何往前计算贡献呢 考虑一下这个乘上其在队列中的位置可以表示为这个数被算了多少次,而我们往前扩展一位当前已经被扩展的就会被计算 ...