This chapter describes how to create and manage ZFS snapshots and clones. Information about saving snapshots is also provided in this chapter.
The following sections are provided in this chapter:
A snapshot is a read-only copy of a file system or volume. Snapshots can be created almost instantly, and initially consume no additional disk space within the pool. However, as data within the active dataset changes, the snapshot consumes disk space by continuing to reference the old data and so prevents the space from being freed.
ZFS snapshots include the following features:
Persist across system reboots.
The theoretical maximum number of snapshots is 264.
Use no separate backing store. Snapshots consume disk space directly from the same storage pool as the file system or volume from which they were created.
Recursive snapshots are created quickly as one atomic operation. The snapshots are created together (all at once) or not created at all. The benefit of atomic snapshot operations is that the snapshot data is always taken at one consistent time, even across descendent file systems.
Snapshots of volumes cannot be accessed directly, but they can be cloned, backed up, rolled back to, and so on. For information about backing up a ZFS snapshot, see Sending and Receiving ZFS Data.
Snapshots are created by using the zfs snapshot command, which takes as its only argument the name of the snapshot to create. The snapshot name is specified as follows:
filesystem@snapname volume@snapname |
The snapshot name must satisfy the naming conventions defined in ZFS Component Naming Requirements.
In the following example, a snapshot of tank/home/ahrens that is named friday is created.
# zfs snapshot tank/home/ahrens@friday |
You can create snapshots for all descendent file systems by using the -r option. For example:
# zfs snapshot -r tank/home@now # zfs list -t snapshot NAME USED AVAIL REFER MOUNTPOINT tank/home@now 0 - 29.5K - tank/home/ahrens@now 0 - 2.15M - tank/home/anne@now 0 - 1.89M - tank/home/bob@now 0 - 1.89M - tank/home/cindys@now 0 - 2.15M - |
Snapshots have no modifiable properties. Nor can dataset properties be applied to a snapshot.
# zfs set compression=on tank/home/ahrens@now cannot set compression property for 'tank/home/ahrens@now': snapshot properties cannot be modified |
Snapshots are destroyed by using the zfs destroy command. For example:
# zfs destroy tank/home/ahrens@now |
A dataset cannot be destroyed if snapshots of the dataset exist. For example:
A dataset cannot be destroyed if snapshots of the dataset exist. For example:
# zfs destroy tank/home/ahrens cannot destroy 'tank/home/ahrens': filesystem has children use '-r' to destroy the following datasets: tank/home/ahrens@tuesday tank/home/ahrens@wednesday tank/home/ahrens@thursday |
In addition, if clones have been created from a snapshot, then they must be destroyed before the snapshot can be destroyed.
For more information about the destroy subcommand, see Destroying a ZFS File System.
If you have different automatic snapshot policies so that older snapshots are being inadvertently destroyed by zfs receive because they no longer exist on the sending side, you might consider using the snapshots hold feature.
Holding a snapshot prevents it from being destroyed. In addition, this feature allows a snapshot with clones to be deleted pending the removal of the last clone by using the zfs destroy -d command. Each snapshot has an associated user-reference count, which is initialized to zero. This count increases by one whenever a hold is put on the snapshot and decreases by one whenever a hold is released.
In the previous Solaris release, snapshots could only be destroyed by using the zfs destroy command if it had no clones. In this Solaris release, the snapshot must also have a zero user-reference count.
You can put a hold a snapshot or set of snapshots. For example, the following syntax puts a hold tag, keep, on tank/home/cindys/snap@1.
# zfs hold keep tank/home/cindys@snap1 |
You can use the -r option to recursively hold the snapshots of all descendent file systems. For example:
# zfs snapshot -r tank/home@now # zfs hold -r keep tank/home@now |
The above syntax adds a single reference, keep, to the given snapshot or snapshots. Each snapshot has its own tag namespace and tags must be unique within that space. If a hold exists on a snapshot, attempts to destroy that snapshot by using the zfs destroy command will fail. For example:
# zfs destroy tank/home/cindys@snap1 cannot destroy 'tank/home/cindys@snap1': dataset is busy |
If you want to destroy a held snapshot, use the -d option. For example:
# zfs destroy -d tank/home/cindys@snap1 |
Use the zfs holds command to display a list of held snapshots. For example:
# zfs holds tank/home@now NAME TAG TIMESTAMP tank/home@now keep Fri Oct 2 12:40:12 2009 |
# zfs holds -r tank/home@now NAME TAG TIMESTAMP tank/home/cindys@now keep Fri Oct 2 12:40:12 2009 tank/home/mark@now keep Fri Oct 2 12:40:12 2009 tank/home@now keep Fri Oct 2 12:40:12 2009 |
You can use the zfs release command to release a hold on a snapshot or set of snapshots. For example:
# zfs release -r keep tank/home@now |
If the snapshot is released, the snapshot can be destroy with the zfs destroy command. For example:
# zfs destroy -r tank/home@now |
Two new properties identify snapshot hold information:
The defer_destroy property is on if the snapshot has been marked for deferred destroy by using the zfs destroy -d command. Otherwise, the property is off.
The userrefs property is set to the number of holds on this snapshot.
You can rename snapshots but they must be renamed within the same pool and dataset from which they were created. For example:
# zfs rename tank/home/cindys@083006 tank/home/cindys@today |
In addition, the following shortcut syntax provides equivalent snapshot renaming syntax as the example above.
# zfs rename tank/home/cindys@083006 today |
The following snapshot rename operation is not supported because the target pool and file system name are different from the pool and file system where the snapshot was created.
# zfs rename tank/home/cindys@today pool/home/cindys@saturday cannot rename to 'pool/home/cindys@today': snapshots must be part of same dataset |
You can recursively rename snapshots with the zfs rename -r command. For example:
# zfs list NAME USED AVAIL REFER MOUNTPOINT users 270K 16.5G 22K /users users/home 76K 16.5G 22K /users/home users/home@yesterday 0 - 22K - users/home/markm 18K 16.5G 18K /users/home/markm users/home/markm@yesterday 0 - 18K - users/home/marks 18K 16.5G 18K /users/home/marks users/home/marks@yesterday 0 - 18K - users/home/neil 18K 16.5G 18K /users/home/neil users/home/neil@yesterday 0 - 18K - # zfs rename -r users/home@yesterday @2daysago # zfs list -r users/home NAME USED AVAIL REFER MOUNTPOINT users/home 76K 16.5G 22K /users/home users/home@2daysago 0 - 22K - users/home/markm 18K 16.5G 18K /users/home/markm users/home/markm@2daysago 0 - 18K - users/home/marks 18K 16.5G 18K /users/home/marks users/home/marks@2daysago 0 - 18K - users/home/neil 18K 16.5G 18K /users/home/neil users/home/neil@2daysago 0 - 18K - |
By default, snapshots are no longer displayed in the zfs list output. You must use the zfs list -t snapshot command to display snapshot information. Or, enable the listsnapshots pool property. For example:
# zpool get listsnapshots tank NAME PROPERTY VALUE SOURCE tank listsnapshots off default # zpool set listsnapshots=on tank # zpool get listsnapshots tank NAME PROPERTY VALUE SOURCE tank listsnapshots on local |
Snapshots of file systems are accessible in the .zfs/snapshot directory within the root of the containing file system. For example, if tank/home/ahrens is mounted on /home/ahrens, then the tank/home/ahrens@thursday snapshot data is accessible in the /home/ahrens/.zfs/snapshot/thursday directory.
# ls /tank/home/ahrens/.zfs/snapshot tuesday wednesday thursday |
You can list snapshots as follows:
# zfs list -t snapshot NAME USED AVAIL REFER MOUNTPOINT pool/home/anne@monday 0 - 780K - pool/home/bob@monday 0 - 1.01M - tank/home/ahrens@tuesday 8.50K - 780K - tank/home/ahrens@wednesday 8.50K - 1.01M - tank/home/ahrens@thursday 0 - 1.77M - tank/home/cindys@today 8.50K - 524K - |
You can list snapshots that were created for a particular file system as follows:
# zfs list -r -t snapshot -o name,creation tank/home NAME CREATION tank/home/ahrens@tuesday Mon Aug 31 11:03 2009 tank/home/ahrens@wednesday Mon Aug 31 11:03 2009 tank/home/ahrens@thursday Mon Aug 31 11:03 2009 tank/home/cindys@now Mon Aug 31 11:04 2009 |
When a snapshot is created, its space is initially shared between the snapshot and the file system, and possibly with previous snapshots. As the file system changes, space that was previously shared becomes unique to the snapshot, and thus is counted in the snapshot's used property. Additionally, deleting snapshots can increase the amount of space unique to (and thus used by) other snapshots.
A snapshot's space referenced property is the same as the file system's was when the snapshot was created.
You can identify additional information about how the values of the used property are consumed. New read-only file system properties describe space usage for clones, file systems, and volumes. For example:
$ zfs list -o space NAME AVAIL USED USEDSNAP USEDDS USEDREFRESERV USEDCHILD rpool 25.4G 7.79G 0 64K 0 7.79G rpool/ROOT 25.4G 6.29G 0 18K 0 6.29G rpool/ROOT/snv_98 25.4G 6.29G 0 6.29G 0 0 rpool/dump 25.4G 1.00G 0 1.00G 0 0 rpool/export 25.4G 38K 0 20K 0 18K rpool/export/home 25.4G 18K 0 18K 0 0 rpool/swap 25.8G 512M 0 111M 401M 0 |
For a description of these properties, see Table 6–1.
The zfs rollback command can be used to discard all changes made since a specific snapshot. The file system reverts to its state at the time the snapshot was taken. By default, the command cannot roll back to a snapshot other than the most recent snapshot.
To roll back to an earlier snapshot, all intermediate snapshots must be destroyed. You can destroy earlier snapshots by specifying the -r option.
If clones of any intermediate snapshots exist, the -R option must be specified to destroy the clones as well.
The file system that you want to roll back is unmounted and remounted, if it is currently mounted. If the file system cannot be unmounted, the rollback fails. The -f option forces the file system to be unmounted, if necessary.
In the following example, the tank/home/ahrens file system is rolled back to the tuesday snapshot:
# zfs rollback tank/home/ahrens@tuesday cannot rollback to 'tank/home/ahrens@tuesday': more recent snapshots exist use '-r' to force deletion of the following snapshots: tank/home/ahrens@wednesday tank/home/ahrens@thursday # zfs rollback -r tank/home/ahrens@tuesday |
In the above example, the wednesday and thursday snapshots are removed because you rolled back to the previous tuesday snapshot.
# zfs list -r -t snapshot -o name,creation tank/home/ahrens NAME CREATION tank/home/ahrens@tuesday Wed Aug 27 16:35 2009 |
The Time Slider snapshot tool automatically snapshots ZFS file systems and allows you to browse and recover snapshots of file systems. This tool provides the following features:
SMF snapshot service instances that schedule reoccurring snapshots
Automatic snapshots are scheduled from the zfssnap crontab
Older snapshots are removed based on a predefined percentage of file system space used
Browse and recover files from snapshots by using the GNOME file manager
You will need to add yourself to the zfssnap role to use the GNOME file manager to modify Time Slider behavior.
When the Time Slider tool is enabled, ZFS file system snapshots are created based on the following criteria:
frequent snapshots every 15 mins, keeping 4 snapshots hourly snapshots every hour, keeping 24 snapshots daily snapshots every day, keeping 31 snapshots weekly snapshots every week, keeping 7 snapshots monthly snapshots every month, keeping 12 snapshots |
Start a privileged shell, if running an OpenSolaris release. Otherwise, become a privileged user.
user@opensolaris:-$ pfexec bash # |
In this example, the bash shell is selected. You can choose to use any shell with the pfexec command. If you support multiple versions of the SolarisTM OS, use the standard su root command. The su command works on all Solaris versions.
Enable the Time Slider service, which is disabled by default.
You can enable or disable these services from the command line or from the System->Preferences->Time Slider Setup menu. From this menu, you can also customize which ZFS file systems to snapshot and adjust the file system capacity setting for when snapshots are removed.
Review the default automatic snapshot service instances that are started when the Time Slider service is enabled.
# svcs | grep auto-snapshot online Oct_22 svc:/system/filesystem/zfs/auto-snapshot:frequent online Oct_22 svc:/system/filesystem/zfs/auto-snapshot:hourly online Oct_22 svc:/system/filesystem/zfs/auto-snapshot:weekly online Oct_22 svc:/system/filesystem/zfs/auto-snapshot:monthly online Oct_22 svc:/system/filesystem/zfs/auto-snapshot:daily |
Confirm that automatic snapshots are created.
For example:
# zfs list -t snapshot NAME USED AVAIL REFER MOUNTPOINT rpool@zfs-auto-snap:weekly-2008-11-13-15:39 0 - 46.5K - rpool@zfs-auto-snap:daily-2008-11-13-15:39 0 - 46.5K - rpool@zfs-auto-snap:hourly-2008-11-13-15:39 0 - 46.5K - rpool@zfs-auto-snap:frequent-2008-11-13-15:39 0 - 46.5K - rpool/ROOT@zfs-auto-snap:weekly-2008-11-13-15:39 0 - 18K - rpool/ROOT@zfs-auto-snap:daily-2008-11-13-15:39 0 - 18K - rpool/ROOT@zfs-auto-snap:hourly-2008-11-13-15:39 0 - 18K - rpool/ROOT@zfs-auto-snap:frequent-2008-11-13-15:39 0 - 18K - . . . |
Disable or enable specific automatic snapshot services for the top-level dataset and all descendent datasets from the command line.
For example:
# zfs set com.sun:auto-snapshot=false rpool # zfs set com.sun:auto-snapshot=true rpool/ROOT/opensolaris |
Choose to only take snapshots under a given schedule for a dataset and all direct descendent datasets from the command line.
For example:
# zfs set com.sun:auto-snapshot=false rpool/export # zfs set com.sun:auto-snapshot:weekly=true rpool/export |
Change the frequency of a given snapshot schedule from the command line.
For example:
# svccfg -s svc:/system/filesystem/zfs/auto-snapshot:frequent setprop zfs/period = 30 # svccfg -s svc:/system/filesystem/zfs/auto-snapshot:frequent refresh # svcadm restart svc:/system/filesystem/zfs/auto-snapshot:frequent |
Disable automatic snapshot services for the swap and dump volumes, from the command line, if necessary.
For example:
# zfs set com.sun:auto-snapshot=false rpool/dump # zfs set com.sun:auto-snapshot=false rpool/swap |
Remove a range of unwanted snapshots, from the command line, if necessary.
For example, remove all automatic snapshots in the bash shell, as follows:
for s in `zfs list -H -o name -t snapshot | grep @zfs-auto-snap`; do zfs destroy $s; done |
You can browse and recover snapshots from the GNOME desktop file manager, which is accessed as follows:
Click the Desktop icon under the Places tab
Click the clock icon with the slider from the Desktop - File Browser
Browse your snapshots by opening any folder in the GNOME file manager.
If the Restore icon (clock with slider ) is enabled, snapshots of this directory are available.
Click on the clock icon to access snapshot navigation features.
Directly below the location: URL section is a one line description of the following information:
The timeline or date and time that the snapshot was taken
The location in the backup timeline of the current snapshot
The number of snapshots available for this directory and the space consumed by ZFS snapshots
Drag the slider into the past to retrieve previous versions of your files.
You can open all your files in read-only mode. Or, you can browse in list view mode (as oppose to icon view) so that a restore information column automatically appears. This column gives you contextual information about either of the following:
The file version number, if you browse in the current or latest version of a directory
The difference, if any, between the file snapshot and the latest version of the file
Recover files from an automatic snapshot from either of the following methods:
Drag and drop a snapshot into another file manager window
Right click the mouse and select the restore to Desktop icon. Then, copy and paste the selected snapshot to the present time.
A clone is a writable volume or file system whose initial contents are the same as the dataset from which it was created. As with snapshots, creating a clone is nearly instantaneous, and initially consumes no additional disk space. In addition, you can snapshot a clone.
Clones can only be created from a snapshot. When a snapshot is cloned, an implicit dependency is created between the clone and snapshot. Even though the clone is created somewhere else in the dataset hierarchy, the original snapshot cannot be destroyed as long as the clone exists. The origin property exposes this dependency, and the zfs destroy command lists any such dependencies, if they exist.
Clones do not inherit the properties of the dataset from which it was created. Use the zfs get and zfs set commands to view and change the properties of a cloned dataset. For more information about setting ZFS dataset properties, see Setting ZFS Properties.
Because a clone initially shares all its disk space with the original snapshot, its used property is initially zero. As changes are made to the clone, it uses more space. The used property of the original snapshot does not consider the disk space consumed by the clone.
To create a clone, use the zfs clone command, specifying the snapshot from which to create the clone, and the name of the new file system or volume. The new file system or volume can be located anywhere in the ZFS hierarchy. The type of the new dataset (for example, file system or volume) is the same type as the snapshot from which the clone was created. You cannot create a clone of a file system in a pool that is different from where the original file system snapshot resides.
In the following example, a new clone named tank/home/ahrens/bug123 with the same initial contents as the snapshot tank/ws/gate@yesterday is created.
# zfs snapshot tank/ws/gate@yesterday # zfs clone tank/ws/gate@yesterday tank/home/ahrens/bug123 |
In the following example, a cloned workspace is created from the projects/newproject@today snapshot for a temporary user as projects/teamA/tempuser. Then, properties are set on the cloned workspace.
# zfs snapshot projects/newproject@today # zfs clone projects/newproject@today projects/teamA/tempuser # zfs set sharenfs=on projects/teamA/tempuser # zfs set quota=5G projects/teamA/tempuser |
ZFS clones are destroyed by using the zfs destroy command. For example:
# zfs destroy tank/home/ahrens/bug123 |
Clones must be destroyed before the parent snapshot can be destroyed.
You can use the zfs promote command to replace an active ZFS file system with a clone of that file system. This feature facilitates the ability to clone and replace file systems so that the original file system becomes the clone of the specified file system. In addition, this feature makes it possible to destroy the file system from which the clone was originally created. Without clone promotion, you cannot destroy an original file system of active clones. For more information about destroying clones, see Destroying a ZFS Clone.
In the following example, the tank/test/productA file system is cloned and then the clone file system, tank/test/productAbeta, becomes the original tank/test/productA file system.
# zfs create tank/test # zfs create tank/test/productA # zfs snapshot tank/test/productA@today # zfs clone tank/test/productA@today tank/test/productAbeta # zfs list -r tank/test NAME USED AVAIL REFER MOUNTPOINT tank/test 314K 8.24G 25.5K /tank/test tank/test/productA 288K 8.24G 288K /tank/test/productA tank/test/productA@today 0 - 288K - tank/test/productAbeta 0 8.24G 288K /tank/test/productAbeta # zfs promote tank/test/productAbeta # zfs list -r tank/test NAME USED AVAIL REFER MOUNTPOINT tank/test 316K 8.24G 27.5K /tank/test tank/test/productA 0 8.24G 288K /tank/test/productA tank/test/productAbeta 288K 8.24G 288K /tank/test/productAbeta tank/test/productAbeta@today 0 - 288K - |
In the above zfs list output, you can see that the space accounting of the original productA file system has been replaced with the productAbeta file system.
Complete the clone replacement process by renaming the file systems. For example:
# zfs rename tank/test/productA tank/test/productAlegacy # zfs rename tank/test/productAbeta tank/test/productA # zfs list -r tank/test NAME USED AVAIL REFER MOUNTPOINT tank/test 316K 8.24G 27.5K /tank/test tank/test/productA 288K 8.24G 288K /tank/test/productA tank/test/productA@today 0 - 288K - tank/test/productAlegacy 0 8.24G 288K /tank/test/productAlegacy |
Optionally, you can remove the legacy file system. For example:
# zfs destroy tank/test/productAlegacy |
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 send ZFS snapshot data and receive ZFS snapshot data and file systems with these commands. See the examples in the next section.
The following backup solutions for saving ZFS data are available:
Enterprise backup products – If you need the following features then consider an enterprise backup solution:
Per-file restoration
Backup media verification
media management
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 Overview of ZFS Snapshots.
Saving snapshots – Use the zfs send and zfs receive commands to send and receive a ZFS snapshot. You can save incremental changes between snapshots, but you cannot restore files individually. You must restore the entire file system snapshot. These commands do not provide a complete backup solution for saving your ZFS data.
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.
Archive utilities – Save ZFS data with archive utilities such as tar, cpio, and pax or third-party backup products. Currently, both tar and cpio translate NFSv4-style ACLs correctly, but pax does not translate NFSv4–style ACLs correctly.
You can use the zfs send command to send a copy of a snapshot and receive the snapshot in another pool on the same system or in another pool on a different system that is used to store backup data. For example, to send the snapshot on a different pool on the same system, use syntax similar to the following:
# zfs send tank/data@snap1 | zfs recv spool/ds01 |
You can use zfs recv as an alias for the zfs receive command.
If you are sending the snapshot stream to a different system, pipe the zfs send output through the ssh command. For example:
host1# zfs send tank/dana@snap1 | ssh host2 zfs recv newtank/dana |
When sending a full stream, the destination file system must not exist.
You can send incremental data by using the zfs send -i option. For example:
host1# zfs send -i tank/dana@snap1 tank/dana@snap2 | ssh host2 zfs recv newtank/dana |
Note that the first argument is the earlier snapshot (snap1) and the second argument (snap2) is the later snapshot. In this case, the newtank/dana file system must exist for the incremental receive to be successful.
The incremental snap1 source can be specified as the last component of the snapshot name. This shortcut means you only have to specify the name after the @ sign for snap1, which is assumed to be from the same file system as snap2. For example:
host1# zfs send -i snap1 tank/dana@snap2 > ssh host2 zfs recv newtank/dana |
This syntax is equivalent to the above example of the incremental syntax.
The following message is displayed if you attempt to generate an incremental stream from a different file system snapshot1:
cannot send 'pool/fs@name': not an earlier snapshot from the same fs |
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 |
Keep the following key points in mind when you receive a file system snapshot:
The snapshot and the file system are received.
The file system and all descendent file systems are unmounted.
The file systems are inaccessible while they are being received.
The original file system to be received must not exist while it is being transferred.
If a conflicting file system name exists, zfs rename can be used to rename the file system.
For example:
# zfs send tank/gozer@0830 > /bkups/gozer.083006 # zfs receive tank/gozer2@today < /bkups/gozer.083006 # zfs rename tank/gozer tank/gozer.old # zfs rename tank/gozer2 tank/gozer |
If you make a change to the destination file system and you want to do another incremental send of a snapshot, you must first rollback the receiving file system.
For example, if you make a change to the file system as follows:
host2# rm newtank/dana/file.1 |
And you do an incremental send of tank/dana@snap3, you must first rollback the receiving file system to receive the new incremental snapshot. You can eliminate the rollback step by using the -F option. For example:
host1# zfs send -i tank/dana@snap2 tank/dana@snap3 | ssh host2 zfs recv -F newtank/dana |
When you receive an incremental snapshot, the destination file system must already exist.
If you make changes to the file system and you do not rollback the receiving file system to receive the new incremental snapshot or you do not use the -F option, you will see the following message:
host1# zfs send -i tank/dana@snap4 tank/dana@snap5 | ssh host2 zfs recv newtank/dana cannot receive: destination has been modified since most recent snapshot |
The following checks are performed before the -F option is successful:
If the most recent snapshot doesn't match the incremental source, neither the rollback nor the receive is completed, and an error message is returned.
If you accidentally provide the name of different file system that doesn't match the incremental source to the zfs receive command, neither the rollback nor the receive is completed, and the following error message is returned.
cannot send 'pool/fs@name': not an earlier snapshot from the same fs |
This section describes how to use the zfs send -I and -R options to send and receive more complex snapshot streams.
Keep the following points in mind when sending and receiving ZFS snapshot streams:
Use the zfs send -I option to send all incremental streams from one snapshot to a cumulative snapshot. Or, use this option to send an incremental stream from the original snapshot to create a clone. The original snapshot must already exist on the receiving side to accept the incremental stream.
Use the zfs send -R option to send a replication stream of all descendent file systems. When received, all properties, snapshots, descendent file systems, and clones are preserved.
Or use both options to send an incremental replication stream.
Changes to properties and snapshot and file system renames and destroys are preserved.
If zfs recv -F is not specified when receiving the replication stream, dataset destroys are ignored. The zfs recv -F syntax in this case also retains its rollback if necessary meaning.
As with other (non zfs send -R) -i or -I cases, if -I is used, all snapshots between snapA and snapD are sent. If -i is used, only snapD (for all descendents) are sent.
To receive any of these new types of zfs send streams, the receiving system must be running a software version capable of sending them. The stream version is incremented.
However, you can access streams from older pool versions by using a newer software version. For example, you can send and receive streams created with the newer options to and from a version 3 pool. But, you must be running recent software to receive a stream sent with the newer options.
A group of incremental snapshots can be combined into one snapshot by using the zfs send -I option. For example:
# zfs send -I pool/fs@snapA pool/fs@snapD > /snaps/fs@all-I |
Remove snapshots B, C, and D.
# zfs destroy pool/fs@snapB # zfs destroy pool/fs@snapC # zfs destroy pool/fs@snapD |
Receive the combined snapshot.
# zfs receive -d -F pool/fs < /snaps/fs@all-I # zfs list NAME USED AVAIL REFER MOUNTPOINT pool 428K 16.5G 20K /pool pool/fs 71K 16.5G 21K /pool/fs pool/fs@snapA 16K - 18.5K - pool/fs@snapB 17K - 20K - pool/fs@snapC 17K - 20.5K - pool/fs@snapD 0 - 21K - |
You can also use the zfs send -I command to combine a snapshot and a clone snapshot to create a combined dataset. For example:
# zfs create pool/fs # zfs snapshot pool/fs@snap1 # zfs clone pool/fs@snap1 pool/clone # zfs snapshot pool/clone@snapA # zfs send -I pool/fs@snap1 pool/clone@snapA > /snaps/fsclonesnap-I # zfs destroy pool/clone@snapA # zfs destroy pool/clone # zfs receive -F pool/clone < /snaps/fsclonesnap-I |
Use the zfs send -R command to replicate a ZFS file system and all descendent file systems, up to the named snapshot. When received, all properties, snapshots, descendent file systems, and clones are preserved.
In the following example, snapshots are created for user file systems. One replication stream is created for all user snapshots. Then, the original file systems and snapshots are destroyed and recovered.
# zfs snapshot -r users@today # zfs list NAME USED AVAIL REFER MOUNTPOINT users 187K 33.2G 22K /users users@today 0 - 22K - users/user1 18K 33.2G 18K /users/user1 users/user1@today 0 - 18K - users/user2 18K 33.2G 18K /users/user2 users/user2@today 0 - 18K - users/user3 18K 33.2G 18K /users/user3 users/user3@today 0 - 18K - # zfs send -R users@today > /snaps/users-R # zfs destroy -r users # zfs receive -F -d users < /snaps/users-R # zfs list NAME USED AVAIL REFER MOUNTPOINT users 196K 33.2G 22K /users users@today 0 - 22K - users/user1 18K 33.2G 18K /users/user1 users/user1@today 0 - 18K - users/user2 18K 33.2G 18K /users/user2 users/user2@today 0 - 18K - users/user3 18K 33.2G 18K /users/user3 users/user3@today 0 - 18K - |
You can use the zfs send -R command to replicate the users dataset and its descendents and send the replicated stream to another pool, users2.
# zfs create users2 mirror c0t1d0 c1t1d0 # zfs receive -F -d users2 < /snaps/users-R # zfs list NAME USED AVAIL REFER MOUNTPOINT users 224K 33.2G 22K /users users@today 0 - 22K - users/user1 33K 33.2G 18K /users/user1 users/user1@today 15K - 18K - users/user2 18K 33.2G 18K /users/user2 users/user2@today 0 - 18K - users/user3 18K 33.2G 18K /users/user3 users/user3@today 0 - 18K - users2 188K 16.5G 22K /users2 users2@today 0 - 22K - users2/user1 18K 16.5G 18K /users2/user1 users2/user1@today 0 - 18K - users2/user2 18K 16.5G 18K /users2/user2 users2/user2@today 0 - 18K - users2/user3 18K 16.5G 18K /users2/user3 users2/user3@today 0 - 18K - |
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 sends the tank/cindy@today snapshot data and receives 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.
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 up-to-date information about issues with ZFS and third-party backup products, please see the or the ZFS FAQ, here:
http://hub.opensolaris.org/bin/view/Community+Group+zfs/faq/#backupsoftware