OMV 社区插件列表中提供了 Backup 插件,可以通过 dd、fsarchiver 和 rsync 三种方式对系统进行备份,但是插件界面只能执行系统备份,无法进行系统还原。

使用插件备份系统非常简单,略去不表,以下主要以 fsarchiver 备份为例记录还原系统的方法。

fsarchiver 备份的文件位于插件中指定目录下的 omvbackup 目录中:

omvbackup$ ls
backup-omv-11-Mar-2020_15-43-35.blkid      backup-omv-11-Mar-2020_18-02-37.blkid
backup-omv-11-Mar-2020_15-43-35.fdisk      backup-omv-11-Mar-2020_18-02-37.fdisk
backup-omv-11-Mar-2020_15-43-35.fsa        backup-omv-11-Mar-2020_18-02-37.fsa
backup-omv-11-Mar-2020_15-43-35.grub       backup-omv-11-Mar-2020_18-02-37.grub
backup-omv-11-Mar-2020_15-43-35.grubparts  backup-omv-11-Mar-2020_18-02-37.grubparts
backup-omv-11-Mar-2020_15-43-35.packages   backup-omv-11-Mar-2020_18-02-37.packages

一次备份会产生以下几种类型的备份文件:

  • .blkid:blkid 命令的输出
  • .fdisk:fdisk -l 命令的输出
  • .fsa:fsarchiver 实际的备份文件
  • .grub:grub 所在的磁盘最前的 446 bytes 数据
  • .grubparts:磁盘的前 512 bytes 包含 grub 和分区表
  • .packages:dpkg -l | grep 命令的输出

系统还原到原磁盘

假设新磁盘设备名为 /dev/sde

omvbackup$ sudo fsarchiver restfs backup-omv-11-Mar-2020_18-02-37.fsa id=0,dest=/dev/sde1

Statistics for filesystem 0
* files successfully processed:....regfiles=36930, directories=4498, symlinks=3205, hardlinks=9, specials=10
* files with errors:...............regfiles=0, directories=0, symlinks=0, hardlinks=0, specials=0

系统还原到新磁盘

假设新磁盘设备名为 /dev/sde

首先,恢复磁盘结构:

omvbackup$ sudo dd if=backup-omv-11-Mar-2020_18-02-37.grubparts of=/dev/sde

1+0 records in
1+0 records out
512 bytes copied, 0.00548499 s, 93.3 kB/s

查看恢复后的分区结构:

omvbackup$ sudo fdisk -l /dev/sde

Disk /dev/sde: 28.7 GiB, 30752636928 bytes, 60063744 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x1851daa6

Device     Boot Start      End  Sectors  Size Id Type
/dev/sde1  *     2048 60061695 60059648 28.7G 83 Linux

然后,将 grub 恢复到 /dev/sde1 分区:

omvbackup$ sudo dd if=backup-omv-11-Mar-2020_18-02-37.grub of=/dev/sde1

0+1 records in
0+1 records out
446 bytes copied, 0.00595929 s, 74.8 kB/s

查看备份文件信息:

omvbackup$ sudo fsarchiver archinfo backup-omv-11-Mar-2020_18-02-37.fsa 

====================== archive information ======================
Archive type: 			filesystems
Filesystems count: 		1
Archive id: 			5e61e054
Archive file format: 		FsArCh_002
Archive created with: 		0.8.1
Archive creation date: 		2020-03-11_18-02-37
Archive label: 			<none>
Minimum fsarchiver version:	0.6.4.0
Compression level: 		3 (gzip level 6)
Encryption algorithm: 		none

===================== filesystem information ====================
Filesystem id in archive: 	0
Filesystem format: 		ext4
Filesystem label: 		
Filesystem uuid: 		e59edec2-d4e7-4e72-8f3b-3a7cb2c2fdf2
Original device: 		/dev/sdd1
Original filesystem size: 	28.06 GB (30131867648 bytes)
Space used in filesystem: 	1.66 GB (1785688064 bytes)

最后,执行系统恢复:

omvbackup$ sudo fsarchiver restfs backup-omv-11-Mar-2020_18-02-37.fsa id=0,dest=/dev/sde1

Statistics for filesystem 0
* files successfully processed:....regfiles=36930, directories=4498, symlinks=3205, hardlinks=9, specials=10
* files with errors:...............regfiles=0, directories=0, symlinks=0, hardlinks=0, specials=0