Send recursively

New to OpenZFS on OS X (Or ZFS in general)? Ask your questions here!

Send recursively

Postby t3hite » Tue Dec 13, 2022 12:15 pm

I'd like to back up my working pool mypool to a backup pool myback. I've created some snapshots on mypool and don't want to send each one separately.

mypool 3.34T 7.44T 7.97M none
mypool/mydocs 198G 7.44T 952K none
mypool/mydocs/Old_docs 198G 7.44T 193G /Volumes/Old_docs
mypool/mydocs/Old_docs@2020-12-10 15.6M - 85.5G -
mypool/mydocs/Old_docs@2020-12-13 16.9M - 113G -
mypool/mydocs/Old_docs@2020-12-15 2.92M - 117G -
mypool/mydocs/Old_docs@2020-12-17 1.06M - 117G -
mypool/mydocs/Old_docs@2020-12-18 7.83M - 117G -
mypool/mydocs/Old_docs@2020-12-20 9.91M - 117G -
mypool/mydocs/Old_docs@2020-12-27 21.1M - 117G -
mypool/mydocs/Old_docs@2022-12-12 128M - 193G -
mypool/mymedia 3.15T 7.44T 952K none
mypool/mymedia/Media-1 1.90T 7.44T 1.72T /Volumes/Media-1
mypool/mymedia/Media-1@2020-12-13 146M - 1.12T -
mypool/mymedia/Media-1@2020-12-20 14.6M - 1.14T -
mypool/mymedia/Media-1@2020-12-27 1.83G - 1.15T -
mypool/mymedia/Media-1@2022-12-12 2.52M - 1.72T -
mypool/mymedia/Media-2 1.25T 7.44T 1.23T /Volumes/Media-2
mypool/mymedia/Media-2@2020-12-13 3.24M - 1.24T -
mypool/mymedia/Media-2@2020-12-20 3.11M - 1.25T -
mypool/mymedia/Media-2@2020-12-27 3.16M - 1.25T -
mypool/mymedia/Media-2@2022-12-12 300K - 1.23T -

I've read some online documentation about the -R &-r options as well as -I & -I but I'm not clear how to proceed. The myback pool is kept offsite so I can accumulate multiple snapshots before doing a transfer.
t3hite
 
Posts: 10
Joined: Sun Nov 10, 2019 10:08 am

Re: Send recursively

Postby Jimbo » Tue Dec 13, 2022 9:19 pm

Take a look at "send -R" (replicate) which will do the file system and all decendent file systems, it might be what you're after.

More specificially, I do something like this for an incremental send of a parent and multiple children:
(Initial version) zfs send -R ${snapshot}
(Incremental version) zfs send -R -I ${snapshot_previous} ${snapshot_today
Jimbo
 
Posts: 149
Joined: Sun Sep 17, 2017 5:12 am

Re: Send recursively

Postby Sharko » Wed Dec 14, 2022 1:11 pm

I do this all the time using the -I flag on send. I like to bracket my commands with 'date' so I know how long the command took to complete. For your situation here are the commands:

Code: Select all
date; zfs send mypool/mydocs/Old_docs@2020-12-10 | zfs receive myback/BACKUP ; date
zfs set readonly=on myback/BACKUP
zfs rollback myback/BACKUP@2020-12-10
date zfs send -I mypool/mydocs/Old_docs@2020-12-10 mypool/mydocs/Old_docs@2022-12-12 |  zfs receive myback/BACKUP ; date


I also like the -R 'replicate' command when you have multiple datasets under a single zpool, but one thing that I think Jimbo forgot to mention is that often you will want to snapshot the whole pool recursively first:
Code: Select all
zfs snapshot -r mypool@2022-12-14


That way you will be guaranteed to have a consistent snapshot in all the datasets under the pool that you want to use with zfs send -R.
Sharko
 
Posts: 242
Joined: Thu May 12, 2016 12:19 pm

Re: Send recursively

Postby t3hite » Thu Dec 15, 2022 11:48 am

That was helpful. I was confuse the -R would begin at the bottom of the pool structure, it actually begins with the most recent snapshot.

My system requires a sudo on both side of the pipe:
sudo zfs send -R mydata/media/zMedia-1@2022-12-14 | sudo zfs receive backup/zMedia-1
t3hite
 
Posts: 10
Joined: Sun Nov 10, 2019 10:08 am


Return to Absolute Beginners Section

Who is online

Users browsing this forum: No registered users and 2 guests

cron