多年以前的笔记
fsarchiver安装
apt-get install fsarchiver
# 对于备份操作,我们需要以只读形式重新挂载文件系统或者有条件的话直接卸载。也可以-A忽略
[peter@test88 ~]$ sudo /home/peter/fsarchiver savefs backup.fsa /dev/sdb1
oper_save.c#938,filesystem_mount_partition(): partition [/dev/sdb1] is mounted read/write. please mount it read-only
and then try again. you can do "mount -o remount,ro /dev/sdb1". you can
also run fsarchiver with option '-A' if you know what you are doing.
removed backup.fsa
# 对于恢复操作,我们必须先卸载文件系统。
[peter@test88 ~]$ sudo /home/peter/fsarchiver restfs backup2.fsa id=0,dest=/dev/sdb2
oper_restore.c#1230,extractar_filesystem_extract(): partition [/dev/sdb2] is mounted on [/home/peter/sder].
cannot restore an archive to a partition which is mounted, unmount it first: umount /home/peter/sder
# 创建文件系统备份
# 可以将多个文件系统备份在一个文件中
[peter@test88 ~]$ sudo /home/peter/fsarchiver savefs backup.fsa /dev/sdb1 /dev/sdb2
# 恢复文件系统
# id=0表明从归档中提取第一个文件系统的内容
[peter@test88 ~]$ sudo /home/peter/fsarchiver restfs backup.fsa id=0,dest=/dev/sdc1 id=1,dest=/dev/sdc2
# 软件说明文档
====> fsarchiver version 0.8.1 (2017-01-10) - http://www.fsarchiver.org <====
Distributed under the GPL v2 license (GNU General Public License v2).
* usage: fsarchiver [<options>] <command> <archive> [<dev1> [<dev2> [...]]]
<commands>
* savefs: save filesystems to an archive file (backup a device to a file)
* restfs: restore filesystems from an archive (overwrites the existing data)
* savedir: save directories to the archive (similar to a compressed tarball)
* restdir: restore data from an archive which is not based on a filesystem
* archinfo: show information about an existing archive file and its contents
* probe [detailed]: show list of filesystems detected on the disks
<options>
-o: overwrite the archive if it already exists instead of failing
-v: verbose mode (can be used several times to increase the level of details)
-d: debug mode (can be used several times to increase the level of details)
-A: allow to save a filesystem which is mounted in read-write (live backup)
-a: allow to save a filesystem when acls and xattrs are not supported
-x: enable support for experimental features (they are disabled by default)
-e <pattern>: exclude files and directories that match that pattern
-L <label>: set the label of the archive (comment about the contents)
-z <level>: compression level from 1 (very fast) to 9 (very good) default=3
-s <mbsize>: split the archive into several files of <mbsize> megabytes each
-j <count>: create more than one (de)compression thread. useful on multi-core cpu
-c <password>: encrypt/decrypt data in archive, "-c -" for interactive password
-h: show help and information about how to use fsarchiver with examples
-V: show program version and exit
<information>
* Support included for: lzo=yes, lzma=yes
* Support for ntfs filesystems is unstable: don't use it for production.
<examples>
* save only one filesystem (/dev/sda1) to an archive:
fsarchiver savefs /data/myarchive1.fsa /dev/sda1
* save two filesystems (/dev/sda1 and /dev/sdb1) to an archive:
fsarchiver savefs /data/myarchive2.fsa /dev/sda1 /dev/sdb1
* restore the first filesystem from an archive (first = number 0):
fsarchiver restfs /data/myarchive2.fsa id=0,dest=/dev/sda1
* restore the second filesystem from an archive (second = number 1):
fsarchiver restfs /data/myarchive2.fsa id=1,dest=/dev/sdb1
* restore two filesystems from an archive (number 0 and 1):
fsarchiver restfs /data/arch2.fsa id=0,dest=/dev/sda1 id=1,dest=/dev/sdb1
* restore a filesystem from an archive and convert it to reiserfs:
fsarchiver restfs /data/myarchive1.fsa id=0,dest=/dev/sda1,mkfs=reiserfs
* restore a filesystem from an archive and specify extra mkfs options:
fsarchiver restfs /data/myarchive1.fsa id=0,dest=/dev/sda1,mkfs=ext4,mkfsopt="-I 256"
* restore a filesystem from an archive and specify a new label and a new UUID:
fsarchiver restfs /data/myarchive1.fsa id=0,dest=/dev/sda1,label=root,uuid=5f6e5f4f-dc2a-4dbd-a6ea-9ca997cde75e
* save the contents of /usr/src/linux to an archive (similar to tar):
fsarchiver savedir /data/linux-sources.fsa /usr/src/linux
* save a filesystem (/dev/sda1) to an archive split into volumes of 680MB:
fsarchiver savefs -s 680 /data/myarchive1.fsa /dev/sda1
* save a filesystem and exclude all files/dirs called 'pagefile.*':
fsarchiver savefs /data/myarchive.fsa /dev/sda1 --exclude='pagefile.*'
* generic exclude for 'share' such as '/usr/share' and '/usr/local/share':
fsarchiver savefs /data/myarchive.fsa --exclude=share
* absolute exclude valid for '/usr/share' but not for '/usr/local/share':
fsarchiver savefs /data/myarchive.fsa --exclude=/usr/share
* save a filesystem (/dev/sda1) to an encrypted archive:
fsarchiver savefs -c mypassword /data/myarchive1.fsa /dev/sda1
* same as before but prompt for password in the terminal:
fsarchiver savefs -c - /data/myarchive1.fsa /dev/sda1
* extract an archive made of simple files to /tmp/extract:
fsarchiver restdir /data/linux-sources.fsa /tmp/extract
* show information about an archive and its filesystems:
fsarchiver archinfo /data/myarchive2.fsa
```
