8.7. Backup and Restoration of XFS File Systems


XFS file system backup and restoration involves two utilities: xfsdump and xfsrestore.
To backup or dump an XFS file system, use the xfsdump utility. Red Hat Enterprise Linux 6 supports backups to tape drives or regular file images, and also allows multiple dumps to be written to the same tape. The xfsdump utility also allows a dump to span multiple tapes, although only one dump can be written to a regular file. In addition, xfsdump supports incremental backups, and can exclude files from a backup using size, subtree, or inode flags to filter them.
In order to support incremental backups, xfsdump uses dump levels to determine a base dump to which a specific dump is relative. The -l option specifies a dump level (0-9). To perform a full backup, perform a level 0 dump on the file system (that is, /path/to/filesystem), as in:
# xfsdump -l 0 -f /dev/device /path/to/filesystem

注意

The -f option specifies a destination for a backup. For example, the /dev/st0 destination is normally used for tape drives. An xfsdump destination can be a tape drive, regular file, or remote tape device.
In contrast, an incremental backup will only dump files that changed since the last level 0 dump. A level 1 dump is the first incremental dump after a full dump; the next incremental dump would be level 2, and so on, to a maximum of level 9. So, to perform a level 1 dump to a tape drive:
# xfsdump -l 1 -f /dev/st0 /path/to/filesystem
Conversely, the xfsrestore utility restores file systems from dumps produced by xfsdump. The xfsrestore utility has two modes: a default simple mode, and a cumulative mode. Specific dumps are identified by session ID or session label. As such, restoring a dump requires its corresponding session ID or label. To display the session ID and labels of all dumps (both full and incremental), use the -I option:
# xfsrestore -I
This will provide output similar to the following:

例 8.4. Session ID and labels of all dumps

file system 0:
	fs id:		45e9af35-efd2-4244-87bc-4762e476cbab
	session 0:
		mount point:	bear-05:/mnt/test
		device:		bear-05:/dev/sdb2
		time:		Fri Feb 26 16:55:21 2010
		session label:	"my_dump_session_label"
		session id:	b74a3586-e52e-4a4a-8775-c3334fa8ea2c
		level:		0
		resumed:	NO
		subtree:	NO
		streams:	1
		stream 0:
			pathname:	/mnt/test2/backup
			start:		ino 0 offset 0
			end:		ino 1 offset 0
			interrupted:	NO
			media files:	1
			media file 0:
				mfile index:	0
				mfile type:	data
				mfile size:	21016
				mfile start:	ino 0 offset 0
				mfile end:	ino 1 offset 0
				media label:	"my_dump_media_label"
				media id:	4a518062-2a8f-4f17-81fd-bb1eb2e3cb4f
xfsrestore: Restore Status: SUCCESS

Simple Mode for xfsrestore

The simple mode allows users to restore an entire file system from a level 0 dump. After identifying a level 0 dump's session ID (that is, session-ID), restore it fully to /path/to/destination using:
# xfsrestore -f /dev/st0 -S session-ID /path/to/destination

注意

The -f option specifies the location of the dump, while the -S or -L option specifies which specific dump to restore. The -S option is used to specify a session ID, while the -L option is used for session labels. The -I option displays both session labels and IDs for each dump.

Cumulative Mode for xfsrestore

The cumulative mode of xfsrestore allows file system restoration from a specific incremental backup, for example, level 1 to level 9. To restore a file system from an incremental backup, simply add the -r option:
# xfsrestore -f /dev/st0 -S session-ID -r /path/to/destination

Interactive Operation

The xfsrestore utility also allows specific files from a dump to be extracted, added, or deleted. To use xfsrestore interactively, use the -i option, as in:
xfsrestore -f /dev/st0 -i
The interactive dialogue will begin after xfsrestore finishes reading the specified device. Available commands in this dialogue include cd, ls, add, delete, and extract; for a complete list of commands, use help.
For more information about dumping and restoring XFS file systems, refer to man xfsdump and man xfsrestore.
Red Hat logoGithubRedditYoutubeTwitter

学习

尝试、购买和销售

社区

关于红帽文档

通过我们的产品和服务,以及可以信赖的内容,帮助红帽用户创新并实现他们的目标。

让开源更具包容性

红帽致力于替换我们的代码、文档和 Web 属性中存在问题的语言。欲了解更多详情,请参阅红帽博客.

關於紅帽

我们提供强化的解决方案,使企业能够更轻松地跨平台和环境(从核心数据中心到网络边缘)工作。

© 2024 Red Hat, Inc.