ZFS How do I properly restore recursive snapshots of a zpool?

I'm trying to figure out how to take regular snapshots of my jails and also send/receive the data to an external drive for a backup solution, but I cannot seem to find my data. My zpool 'iocage' gets a snapshot with "zfs snapshot -r iocage@`date +"%Y-%m-%d"`. This will give something like this:

Code:
iocage@2017-08-06                                           0      -    28K  -
iocage/iocage@2017-08-06                                16.5K      -  26.5K  -
iocage/iocage/download@2017-08-06                         13K      -    23K  -
iocage/iocage/download/11.1-RELEASE@2017-08-06              0      -   119M  -
iocage/iocage/images@2017-08-06                           13K      -    23K  -
iocage/iocage/jails@2017-08-06                            14K      -    24K  -
iocage/iocage/jails/homeBackup@2017-08-06                 14K      -  25.5K  -
iocage/iocage/jails/homeBackup/data@2017-08-06              0      -    23K  -
iocage/iocage/jails/homeBackup/root@2017-08-06           151K      -   528M  -

So in this case, I want to restore everything in zpool 'iocage' that was taken at 2017-08-06. Would I have to go through the list and select each one of those subvolumes individually or is there some sort of command that I can use that would restore that entire dataset if I did a zfs send to my destination?
 
I'm trying to figure out how to take regular snapshots of my jails and also send/receive the data to an external drive for a backup solution, but I cannot seem to find my data. My zpool 'iocage' gets a snapshot with "zfs snapshot -r iocage@`date +"%Y-%m-%d"`.
Then you can use zfs list -rt snapshot iocage to see your snapshots.

The data is normally only accessed through use of the zfs command, but you can access the snapshots manually too by entering the always hidden .zfs directory which resides in the root of a filesystem.

So, for example:

Code:
peter@breve:~/bin# zfs list -r zroot
NAME                    USED  AVAIL  REFER  MOUNTPOINT
zroot                  23.5G  9.20G  3.33G  /
zroot/doc               334M  9.20G   334M  /usr/doc
zroot/home             2.53G  9.20G  1.94G  /home
zroot/local            5.05G  9.20G  4.97G  /usr/local
zroot/ports            3.81G  9.20G   209M  /usr/ports
This would mean that I can access the snapshots for my users in /home/.zfs/snapshot.

So in this case, I want to restore everything in zpool 'iocage' that was taken at 2017-08-06. Would I have to go through the list and select each one of those subvolumes individually or is there some sort of command that I can use that would restore that entire dataset if I did a zfs send to my destination?
You can only make snapshots (and thus restore things) on a per-filesystem basis. You can't roll back entire pools. Of course you could roll back all the available filesystems to a certain point but I'd be careful with that.

Anyway, the command you need is zfs rollback <snapshot>, see also zfs(8).

And of course you can duplicate the whole thing if you want. You can use zfs send which would dump the snapshot to the console, then you can redirect the stream to either a file or use ssh to send it to another destination where you could use the same SSH session to initiate a zfs receive.
 
And of course you can duplicate the whole thing if you want. You can use zfs send which would dump the snapshot to the console, then you can redirect the stream to either a file or use ssh to send it to another destination where you could use the same SSH session to initiate a zfs receive.

Hey ShelLuser, this is essentially what I'm trying to do. In my experimenting, I would take my snapshot of 'iocage' and then send/receive the snapshot to an external HDD and continue to do that for incremental updates. It SEEMS the data is transferred to my external drive just fine (says the right amount of GB on the external drive), but when I put up a test machine and restore the snapshot backup to that (simulating a failed and rebuilt system), it seems if I restore 'icage@`date`' I don't get what is in 'iocage/iocage/jails@`date`' or 'iocage/iocage/jails/homeBackup@`date`'. So I'm wondering if I have to do this:

zfs send iocage@`date` | zfs receive iocage
zfs send iocage/iocage/jails@`date` | zfs receive iocage/iocage/jails

and so on with everything else, or if there's just some recursive way to say I want to restore everything recursively from 'iocage@`date` via send/receive to restore an entire zpool, and none of this in the sense of doing a rollback
 
I'm late to this thread by about 5 years, but anyone else coming to this thread,
Hey ShelLuser, this is essentially what I'm trying to do. In my experimenting, I would take my snapshot of 'iocage' and then send/receive the snapshot to an external HDD and continue to do that for incremental updates. It SEEMS the data is transferred to my external drive just fine (says the right amount of GB on the external drive), but when I put up a test machine and restore the snapshot backup to that (simulating a failed and rebuilt system), it seems if I restore 'icage@`date`' I don't get what is in 'iocage/iocage/jails@`date`' or 'iocage/iocage/jails/homeBackup@`date`'. So I'm wondering if I have to do this:

zfs send iocage@`date` | zfs receive iocage
zfs send iocage/iocage/jails@`date` | zfs receive iocage/iocage/jails

and so on with everything else, or if there's just some recursive way to say I want to restore everything recursively from 'iocage@`date` via send/receive to restore an entire zpool, and none of this in the sense of doing a rollback
I'm about 5 years late to this thread, but if anyone stumbles across this post, there are two answers:

First, stratacast1, you need to add the -R option to send, in order to replicated descendant filesystems.

Second, I can't find a way to recursively restore either. Seems like an odd thing not to have on a filesystem designed for snapshot backup/recoveries.

You could make a small script to find all of them, and then maybe | xargs the rollbacks. Something like this:

zfs list -rt snapshot mydataset | grep 'YYYYMMDD' | awk '{print $1}' | xargs -I@ zfs -rRf rollback @

Be careful with that little code snippet. You could lose A LOT of data all at once if you don't actually want to roll back.
 
Back
Top