Saving and Restoring ZFS Data
The zfs send command creates a stream representation of a snapshot that is written to standard output. By default, a full stream is generated. You can redirect the output to a file or to a different system. The zfs receive command creates a snapshot whose contents are specified in the stream that is provided on standard input. If a full stream is received, a new file system is created as well. You can save ZFS snapshot data and restore ZFS snapshot data and file systems with these commands. See the examples in the next section.
The following solutions for saving ZFS data are provided:
Saving ZFS snapshots and rolling back snapshots, if necessary.
Saving full and incremental copies of ZFS snapshots and restoring the snapshots and file systems, if necessary.
Remotely replicating ZFS file systems by saving and restoring ZFS snapshots and file systems.
Saving ZFS data with archive utilities such as tar and cpio or third-party backup products.
Consider the following when choosing a solution for saving ZFS data:
File system snapshots and rolling back snapshots – Use the zfs snapshot and zfs rollback commands if you want to easily create a copy of a file system and revert back to a previous file system version, if necessary. For example, if you want to restore a file or files from a previous version of a file system, you could use this solution.
For more information about creating and rolling back to a snapshot, see ZFS Snapshots.
Saving snapshots – Use the zfs send and zfs receive commands to save and restore a ZFS snapshot. You can save incremental changes between snapshots, but you cannot restore files individually. You must restore the entire file system snapshot.
Remote replication – Use the zfs send and zfs receive commands when you want to copy a file system from one system to another. This process is different from a traditional volume management product that might mirror devices across a WAN. No special configuration or hardware is required. The advantage of replicating a ZFS file system is that you can re-create a file system on a storage pool on another system, and specify different levels of configuration for the newly created pool, such as RAID-Z, but with identical file system data.
Saving ZFS Data With Other Backup Products
In addition to the zfs send and zfs receive commands, you can also use archive utilities, such as the tar and cpio commands, to save ZFS files. All of these utilities save and restore ZFS file attributes and ACLs. Check the appropriate options for both the tar and cpio commands.
For update-to-date information about issues with ZFS and third-party backup products, please see the Solaris Express release notes.
Saving a ZFS Snapshot
The simplest form of the zfs send command is to save a copy of a snapshot. For example:
# zfs send tank/dana@040706 > /dev/rmt/0
You can save incremental data by using the zfs send i option. For example:
# zfs send -i tank/dana@040706 tank/dana@040806 > /dev/rmt/0
Note that the first argument is the earlier snapshot and the second argument is the later snapshot.
If you need to store many copies, you might consider compressing a ZFS snapshot stream representation with the gzip command. For example:
# zfs send pool/fs@snap | gzip > backupfile.gz
Restoring a ZFS Snapshot
When you restore a file system snapshot, the file system is restored as well. The file system is unmounted and is inaccessible while it is being restored. In addition, the original file system to be restored must not exist while it is being restored. If a conflicting file system name exists, zfs rename can be used to rename the file system. For example:
# zfs send tank/gozer@040706 > /dev/rmt/0
.
.
.
# zfs receive tank/gozer2@today < /dev/rmt/0
# zfs rename tank/gozer tank/gozer.old
# zfs rename tank/gozer2 tank/gozer
You can use zfs recv as an alias for the zfs receive command.
When you restore an incremental file system snapshot, the most recent snapshot must first be rolled back. In addition, the destination file system must exist. In the following example, the previous incremental saved copy of tank/dana is restored.
# zfs rollback tank/dana@040706
cannot rollback to 'tank/dana@040706': more recent snapshots exist
use '-r' to force deletion of the following snapshots:
tank/dana@now
# zfs rollback -r tank/dana@040706/
# zfs recv tank/dana < /dev/rmt/0
During the incremental restore process, the file system is unmounted and cannot be accessed.
Remote Replication of ZFS Data
You can use the zfs send and zfs recv commands to remotely copy a snapshot stream representation from one system to another system. For example:
# zfs send tank/cindy@today | ssh newsys zfs recv sandbox/restfs@today
This command saves the tank/cindy@today snapshot data and restores it into the sandbox/restfs file system and also creates a restfs@today snapshot on the newsys system. In this example, the user has been configured to use ssh on the remote system.
Courtesy: http://docs.huihoo.com/opensolaris/solaris-zfs-administration-guide/html/ch06s03.html#gbimy
No comments:
Post a Comment