Quick HowTo: xfsdump & xfsrestore
Originally this was posted last year as a blog post. But now I've created a article content type I figured it could go here.
About XFS
XFS is the journaling file-system created by SGI originally for their IRIX UNIX platform, primarily intended for media/video intensive applications on their MIPS based workstations.
SGI ported XFS to the Linux kernel, and by 2002 it was in the main kernel base.
I've used it as my main file-system now for my servers and desktop machines under Linux for several years.
Its fast, its reliable, and its very fault tolerant I've found. I've had very few problems with data loss (actually none due to XFS itself) since switching.
SGI also ported the xfsdump and xfsrestore programs over to Linux.
xfsdump
xfsdump can be used to take image of an entire xfs file-system to either tape, removable media (cdr, dvdr), hard drives or a file.
The basic command for doing a basic level 0 dump of a file-system (we'll use /home here) to tape would be:
xfsdump -l 0 -p 30 -f /dev/st0 /home
That would take the contents of the /home file-system and dump it to the scsi tape at /dev/st0
It is important to note that xfsdump works at the file-system (or below) level, so it doesn't much care about mount points. It will also only dump an XFS file-system.
When using tapes or other removable media, sometimes it is necessary to pre-erase. Use the -E switch for that, -o to overwrite the tape and -F for force (no prompt). BE CAREFUL with them though!
xfsdump will time out dialogues when requesting a new tape or confirmation, -T can be used to prevent this.
-R can be used to resume a previously interrupted dump or restore.
You can also specify labels for the dumps.
There are two, Session Labels, and Media Labels. xfsdump keeps an inventory of dumps, which allows you to do incremental dumps after you've done the first level 0 dump.
The labels can be added on the command line using the following:
- -L - specifies the Session Label
-M - specifies the Media Label
Alternatively you can manually enter them when xfsdump prompts for them.
Once a level 0 dump has been made, you can do other level dumps (incremental) later by using -l 1 and so on.
You can use -s to specify subtree items of a file-system. Using this method means you can't do incremental dumps however, and you can select using chattr which parts of a file-system should be backed up and which shouldn't.
The following:
xfsdump -l 0 -p 30 -f /backups/home-backup /home
Would back up the contents of /home to the file home-backup in the /backups directory.
It is also possible to use xfsdump across the network in combination with ssh and |. This way remote backups are possible, for instance to a remote tape drive.
xfsrestore
xfsrestore works similarly to xfsdump.
It also has an interactive mode, whereby you can select which parts of the dump to restore.
xfsrestore -i -f /backups/home-backup /newhome
Would give you the interactive restore screen, allowing you to selective select parts of the file-system using the commands available (type help for a list). Once added, type extract and the restore process will begin.
If you want status updates every 60 seconds you can also add -p 60 to the command line for instance.
xfsrestore -p 60 -i -f /backups/home-backup /newhome
Would give you updates every 60 seconds.
This has mostly been for my own benefit as something to refer back to.
There is a lot more that xfsdump and xfsrestore can do, see the respective man pages.
- Add new comment
- 915 reads

