Sending and Receiving Complex ZFS Snapshot Streams
This section describes how to use the -I and -R options with the zfs send command to send and receive more complex snapshot streams.
               
Keep the following points in mind when sending and receiving complex ZFS snapshot streams:
- 
                     
                     To send all incremental streams from one snapshot to a cumulative snapshot, use the -Ioption. You can also 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.
- 
                     
                     To send a replication stream of all descendant file systems, use the -Roption. When the replication stream is received, all properties, snapshots, descendant file systems, and clones are preserved.
- 
                     
                     Using the zfs send -rcommand or thezfs send -Rcommand to send package streams without the-coption will omit theoriginof clones in some circumstances. For more information, see Types of ZFS Snapshot Streams.
- 
                     
                     Use both options to send an incremental replication stream. - 
                           
                           Changes to properties are preserved, as are snapshot and file system renameanddestroyoperations.
- 
                           
                           If the -Foption is not specified when receiving the replication stream, datasetdestroyoperations are ignored. Thus, if necessary, you can undo the receive operation and restore the file system to its previous state.
- 
                           
                           When sending incremental streams, if -Iis used, all snapshots betweensnapAandsnapDare sent. If-iis used, onlysnapD(for all descendants) snapshots are sent.
 
- 
                           
                           
- 
                     
                     To receive any of these types of zfs sendstreams, the receiving system must be running a software version capable of sending them. The stream version is incremented.
Example 8-4 Sending and Receiving Complex ZFS Snapshot Streams
You can combine A group of incremental snapshots into one snapshot by using the -I option. For example:
                  
$ zfs send -I pool/fs@snapA pool/fs@snapD > /snaps/fs@all-I
                  You would then remove the incremental snapB, snapC, and snapD snapshots.
                  
$ zfs destroy pool/fs@snapB $ zfs destroy pool/fs@snapC $ zfs destroy pool/fs@snapD
To receive the combined snapshot, you would use the following command.
$ 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 -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
To replicate a ZFS file system and all descendant file systems up to the named snapshot, use the -R option. When this stream is received, all properties, snapshots, descendant file systems, and clones are preserved.
                  
The following example creates snapshots for user file systems. One replication stream is created for all user snapshots. Next, the original file systems and snapshots are destroyed and then 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 -
The following example uses the -R command to replicate the users file system and its descendants, and to 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 -