dump - 備份 | restore - 還原

dump - 備份 | restore - 還原

  1. 確認系統是否有yum雲的dump抓包工具,原因dump默認6.3版本沒有安裝
[root@localhost ~]# rpm -qa | grep dump
system-config-kdump-2.0.5-18.el6.noarch
tcpdump-4.0.0-9.20090921gitdf3cb4.2.el6.x86_64
  1. 確認好了可以yum安裝了
[root@localhost ~]# yum -y install dump
已加載插件:fastestmirror, refresh-packagekit, security
已安裝:
  dump.x86_64 1:0.4-0.6.b42.el6                                                                                            
作爲依賴被安裝:
  rmt.x86_64 1:0.4-0.6.b42.el6
  1. 安裝成功
[root@localhost ~]# rpm -qa | grep dump
system-config-kdump-2.0.5-18.el6.noarch
tcpdump-4.0.0-9.20090921gitdf3cb4.2.el6.x86_64
dump-0.4-0.6.b42.el6.x86_64
  1. 查看要備份的分區
[root@localhost ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        15G  4.0G   10G  29% /
tmpfs           2.0G   72K  2.0G   1% /dev/shm
/dev/sda1       190M   39M  142M  22% /boot
  1. 進行備份boot分區所有文件並把它保存到/tmp/目錄下
[root@localhost tmp]# dump -0uj -f /tmp/boot.bak.bz2 /boot/
  DUMP: Date of this level 0 dump: Fri May  8 10:46:42 2020
  DUMP: Dumping /dev/sda1 (/boot) to /tmp/boot.bak.bz2
  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 37808 blocks.
  DUMP: Volume 1 started with block 1 at: Fri May  8 10:46:42 2020
  DUMP: dumping (Pass III) [directories]
  DUMP: dumping (Pass IV) [regular files]
  DUMP: Closing /tmp/boot.bak.bz2
  DUMP: Volume 1 completed at: Fri May  8 10:46:47 2020
  DUMP: Volume 1 took 0:00:05
  DUMP: Volume 1 transfer rate: 7071 kB/s
  DUMP: Volume 1 37920kB uncompressed, 35356kB compressed, 1.073:1
  DUMP: 37920 blocks (37.03MB) on 1 volume(s)
  DUMP: finished in 5 seconds, throughput 7584 kBytes/sec
  DUMP: Date of this level 0 dump: Fri May  8 10:46:42 2020
  DUMP: Date this dump completed:  Fri May  8 10:46:47 2020
  DUMP: Average transfer rate: 7071 kB/s
  DUMP: Wrote 37920kB uncompressed, 35356kB compressed, 1.073:1
  DUMP: DUMP IS DONE
  1. 查看備份成功後的信息
[root@localhost tmp]# cd /tmp/
[root@localhost tmp]# ll
總用量 35360
-rw-r--r--. 1 root root 36205112 5月   8 10:46 boot.bak.bz2
  • 備份日誌:
[root@localhost etc]# cat dumpdates
/dev/sda1 0 Fri May  8 10:46:42 2020 +0800
  1. 拷貝一個文件到boot目下我們做下增量備份
[root@localhost boot]# ll -h
-rw-------. 1 root root  25M 3月   4 19:05 initramfs-2.6.32-642.el6.x86_64.img
 [root@localhost boot]# cp initramfs-2.6.32-642.el6.x86_64.img initramfs-2.6.32-642.el6.x86_64.tmp
[root@localhost boot]# ll -h 
-rw-------. 1 root root  25M 3月   4 19:05 initramfs-2.6.32-642.el6.x86_64.img
-rw-------. 1 root root  25M 5月   8 10:51 initramfs-2.6.32-642.el6.x86_64.tmp
  • 發現/boot 增加了 64M - 39M = 25M
[root@localhost boot]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda2        15G  4.1G  9.9G  29% /
tmpfs           2.0G   72K  2.0G   1% /dev/shm
/dev/sda1       190M   64M  117M  36% /boot
  1. 第一次增量備份代碼
[root@localhost boot]# dump -1uj -f /tmp/boot.bak1.bz2 /boot
  DUMP: Date of this level 1 dump: Fri May  8 10:52:13 2020
  DUMP: Date of last level 0 dump: Fri May  8 10:46:42 2020
  DUMP: Dumping /dev/sda1 (/boot) to /tmp/boot.bak1.bz2
  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 25073 blocks.
  DUMP: Volume 1 started with block 1 at: Fri May  8 10:52:13 2020
  DUMP: dumping (Pass III) [directories]
  DUMP: dumping (Pass IV) [regular files]
  DUMP: Closing /tmp/boot.bak1.bz2
  DUMP: Volume 1 completed at: Fri May  8 10:52:16 2020
  DUMP: Volume 1 took 0:00:03
  DUMP: Volume 1 transfer rate: 8349 kB/s
  DUMP: Volume 1 25120kB uncompressed, 25049kB compressed, 1.003:1
  DUMP: 25120 blocks (24.53MB) on 1 volume(s)
  DUMP: finished in 3 seconds, throughput 8373 kBytes/sec
  DUMP: Date of this level 1 dump: Fri May  8 10:52:13 2020
  DUMP: Date this dump completed:  Fri May  8 10:52:16 2020
  DUMP: Average transfer rate: 8349 kB/s
  DUMP: Wrote 25120kB uncompressed, 25049kB compressed, 1.003:1
  DUMP: DUMP IS DONE
  1. 查看增量備份的大小很小的速度也很快
[root@localhost boot]# ll -h /tmp/
總用量 59M
-rw-r--r--. 1 root root 25M 5月   8 10:52 boot.bak1.bz2
-rw-r--r--. 1 root root 35M 5月   8 10:46 boot.bak.bz2
  • 備份日誌:
[root@localhost boot]# cat /etc/dumpdates
/dev/sda1 0 Fri May  8 10:46:42 2020 +0800
/dev/sda1 1 Fri May  8 10:52:13 2020 +0800
  1. 查看分區的備份等級及記錄
[root@localhost boot]# dump -W
Last dump(s) done (Dump '>' file systems):
> /dev/sda2     (     /) Last dump: never
  /dev/sda1     ( /boot) Last dump: Level 1, Date Fri May  8 10:52:13 2020
  1. 還原數據
  • 在/tmp中新建一個目錄:
[root@localhost tmp]# pwd
/tmp
[root@localhost tmp]# mkdir boot_bak
  • 進行完全備份還原:
[root@localhost boot_bak]# restore -r -f /tmp/boot.bak.bz2 
Dump tape is compressed.
  • 查看:
[root@localhost boot_bak]# ll -h
總用量 37M
-rw-r--r--. 1 root root 106K 5月  11 2016 config-2.6.32-642.el6.x86_64
drwxr-xr-x. 3 root root 4.0K 3月   4 19:02 efi
drwxr-xr-x. 2 root root 4.0K 3月   4 11:10 grub
-rw-------. 1 root root  25M 3月   4 19:05 initramfs-2.6.32-642.el6.x86_64.img
-rw-------. 1 root root 5.1M 3月   4 19:08 initrd-2.6.32-642.el6.x86_64kdump.img
drwx------. 2 root root 4.0K 3月   4 18:55 lost+found
-rw-------. 1 root root  93K 5月   8 11:11 restoresymtable
-rw-r--r--. 1 root root 211K 5月  11 2016 symvers-2.6.32-642.el6.x86_64.gz
-rw-r--r--. 1 root root 2.5M 5月  11 2016 System.map-2.6.32-642.el6.x86_64
-rwxr-xr-x. 1 root root 4.1M 5月  11 2016 vmlinuz-2.6.32-642.el6.x86_64
  • 增量還原:
[root@localhost boot_bak]# restore -r -f /tmp/boot.bak1.bz2 
Dump tape is compressed.

發現多了第7行:

[root@localhost boot_bak]# ll -h
總用量 61M
-rw-r--r--. 1 root root 106K 5月  11 2016 config-2.6.32-642.el6.x86_64
drwxr-xr-x. 3 root root 4.0K 3月   4 19:02 efi
drwxr-xr-x. 2 root root 4.0K 3月   4 11:10 grub
-rw-------. 1 root root  25M 3月   4 19:05 initramfs-2.6.32-642.el6.x86_64.img
-rw-------. 1 root root  25M 5月   8 10:51 initramfs-2.6.32-642.el6.x86_64.tmp
-rw-------. 1 root root 5.1M 3月   4 19:08 initrd-2.6.32-642.el6.x86_64kdump.img
drwx------. 2 root root 4.0K 3月   4 18:55 lost+found
-rw-------. 1 root root  93K 5月   8 11:13 restoresymtable
-rw-r--r--. 1 root root 211K 5月  11 2016 symvers-2.6.32-642.el6.x86_64.gz
-rw-r--r--. 1 root root 2.5M 5月  11 2016 System.map-2.6.32-642.el6.x86_64
-rwxr-xr-x. 1 root root 4.1M 5月  11 2016 vmlinuz-2.6.32-642.el6.x86_64

注意:

	  備份文件和目錄時,只能使用0級別進行完全備份,而不再支持增量備份
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章