标签:
用tar备份系统实例练习 1. 先处理要放置备份资料的目录与权限: [root@localhost ~]# mkdir /backups [root@localhost ~]# chmod 700 /backups [root@localhost ~]# ll -d /backups drwx------ 2 root root 4096 11-05 16:48 /backups [root@localhost ~]# 2.建立备份文件backup-system-20081130.tar.bz2 [root@localhost ~]# tar -jcv -f /backups/backup-system-20141105.tar.bz2 > --exclude=/root/*.bz2 --exclude=/root/*.gz --exclude=/home/loop* > /etc /home /var/spool/mail /var/spool/cron /root [root@localhost ~]# ll -h /backups/ 总计 4.0K -rw-r--r-- 1 root root 46 11-05 16:50 backup-system-20081130.tar.bz2 完整备份工具:dump 备份最小文件系统 [root@localhost ~]# df -h 文件系统 容量 已用 可用 已用% 挂载点 /dev/sda2 9.5G 1.1G 8.0G 12% / /dev/sda5 8.9G 149M 8.3G 2% /home /dev/sda1 99M 12M 83M 13% /boot tmpfs 506M 0 506M 0% /dev/shm 先测试一下,如果要备份此档案系统,需多少容量? [root@localhost ~]# dump -S /dev/sda1 6048768 开始完整备份 [root@localhost ~]# dump -0u -f /root/boot.dump /boot DUMP: Date of this level 0 dump: Wed Nov 5 16:57:41 2014 DUMP: Dumping /dev/sda1 (/boot) to /root/boot.dump DUMP: Label: /boot DUMP: Writing 10 Kilobyte records DUMP: mapping (Pass I) [regular files] DUMP: mapping (Pass II) [directories] DUMP: estimated 5907 blocks. DUMP: Volume 1 started with block 1 at: Wed Nov 5 16:57:41 2014 DUMP: dumping (Pass III) [directories] DUMP: dumping (Pass IV) [regular files] DUMP: Closing /root/boot.dump DUMP: Volume 1 completed at: Wed Nov 5 16:57:41 2014 DUMP: Volume 1 5960 blocks (5.82MB) DUMP: 5960 blocks (5.82MB) on 1 volume(s) DUMP: finished in less than a second DUMP: Date of this level 0 dump: Wed Nov 5 16:57:41 2014 DUMP: Date this dump completed: Wed Nov 5 16:57:41 2014 DUMP: Average transfer rate: 0 kB/s DUMP: DUMP IS DONE [root@localhost ~]# ll /root/boot.dump /etc/dumpdates -rw-rw-r-- 1 root disk 43 11-05 16:57 /etc/dumpdates -rw-r--r-- 1 root root 6103040 11-05 16:57 /root/boot.dump [root@localhost ~]# cat /etc/dumpdates /dev/sda1 0 Wed Nov 5 16:57:41 2014 +0800 [root@localhost ~]# dump -W Last dump(s) done (Dump ‘>‘ file systems): > /dev/sda2 ( /) Last dump: never > /dev/sda5 ( /home) Last dump: never /dev/sda1 ( /boot) Last dump: Level 0, Date Wed Nov 5 16:57:41 2014 建立level 1的备份 [root@localhost ~]# dd if=/dev/zero of=/boot/testing.img bs=1M count=10 10+0 records in 10+0 records out 10485760 bytes (10 MB) copied, 0.34765 seconds, 30.2 MB/s [root@localhost ~]# dump -1u -f /root/boot.dump.1 /boot DUMP: Date of this level 1 dump: Wed Nov 5 17:00:53 2014 DUMP: Date of last level 0 dump: Wed Nov 5 16:57:41 2014 DUMP: Dumping /dev/sda1 (/boot) to /root/boot.dump.1 DUMP: Label: /boot DUMP: Writing 10 Kilobyte records DUMP: mapping (Pass I) [regular files] DUMP: mapping (Pass II) [directories] DUMP: estimated 10283 blocks. DUMP: Volume 1 started with block 1 at: Wed Nov 5 17:00:53 2014 DUMP: dumping (Pass III) [directories] DUMP: dumping (Pass IV) [regular files] DUMP: Closing /root/boot.dump.1 DUMP: Volume 1 completed at: Wed Nov 5 17:00:54 2014 DUMP: Volume 1 10300 blocks (10.06MB) DUMP: Volume 1 took 0:00:01 DUMP: Volume 1 transfer rate: 10300 kB/s DUMP: 10300 blocks (10.06MB) on 1 volume(s) DUMP: finished in 1 seconds, throughput 10300 kBytes/sec DUMP: Date of this level 1 dump: Wed Nov 5 17:00:53 2014 DUMP: Date this dump completed: Wed Nov 5 17:00:54 2014 DUMP: Average transfer rate: 10300 kB/s DUMP: DUMP IS DONE [root@localhost ~]# ll /root/boot* -rw-r--r-- 1 root root 6103040 11-05 16:57 /root/boot.dump -rw-r--r-- 1 root root 10547200 11-05 17:00 /root/boot.dump.1 [root@localhost ~]# dump -W Last dump(s) done (Dump ‘>‘ file systems): > /dev/sda2 ( /) Last dump: never > /dev/sda5 ( /home) Last dump: never /dev/sda1 ( /boot) Last dump: Level 1, Date Wed Nov 5 17:00:53 2014 用dump 备份非档案系统,亦即单一目录的方法 [root@localhost ~]# dump -0j -f /root/etc.dump.bz2 /etc DUMP: Date of this level 0 dump: Wed Nov 5 17:02:54 2014 DUMP: Dumping /dev/sda2 (/ (dir etc)) to /root/etc.dump.bz2 DUMP: Label: / 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 58325 blocks. DUMP: Volume 1 started with block 1 at: Wed Nov 5 17:02:55 2014 DUMP: dumping (Pass III) [directories] DUMP: dumping (Pass IV) [regular files] DUMP: Closing /root/etc.dump.bz2 DUMP: Volume 1 completed at: Wed Nov 5 17:03:09 2014 DUMP: Volume 1 took 0:00:14 DUMP: Volume 1 transfer rate: 516 kB/s DUMP: Volume 1 64590kB uncompressed, 7232kB compressed, 8.932:1 DUMP: 64590 blocks (63.08MB) on 1 volume(s) DUMP: finished in 13 seconds, throughput 4968 kBytes/sec DUMP: Date of this level 0 dump: Wed Nov 5 17:02:54 2014 DUMP: Date this dump completed: Wed Nov 5 17:03:09 2014 DUMP: Average transfer rate: 516 kB/s DUMP: Wrote 64590kB uncompressed, 7232kB compressed, 8.932:1 DUMP: DUMP IS DONE [root@localhost ~]# restore -t [-f dumpfile] [-h] <==用来察看dump 档 [root@localhost ~]# restore -C [-f dumpfile] [-D 挂载点] <==比较dump 与实际档案 [root@localhost ~]# restore -i [-f dumpfile] <==进入互动模式 [root@localhost ~]# restore -r [-f dumpfile] <==还原整个档案系统选项与参数:
标签:
原文地址:http://www.cnblogs.com/cphome/p/5095695.html