ZFS Rotating backup disks and zfs

I started rotating my personal backups offsite backing up to my drive with the ZAP utility. On my first attempt, I saw that ZAP doesn't see old snapshots, therefore, it will only replicate the most recent one. What would be the best way to replicate those old snapshots to the external HDD? My guess is something like

zfs send -R zroot/datasets | zfs receive zap@backup/datasets

I think it would also make more sense to do this from the host since I'm rotating drives and keeping the backup zpool name the same so I don't have to go changing zfs settings related to ZAP
 
As usual "best" is in the eye of the beholder, there really isn't a clear cut best solution here.

I basically wrote a script to handle this for me. One manages my daily snapshots which are all named after the current date:

Code:
CURDAT=$(date "+%d%m%y");
PRVDAT=$(date -v-${RETENTION}d "+%d%m%y");

<snip>

$(zfs snapshot ${OPTS} ${ZFS}@${CURDAT} > /dev/null 2>&1) || echo "${PROG}: Error creating snapshot ${ZFS}@${CURDAT}" > /dev/stderr
$(zfs destroy ${OPTS} ${ZFS}@${PRVDAT} > /dev/null 2>&1) || echo "${PROG}: Error destroying snapshot ${ZFS}@${PRVDAT}" > /dev/stderr
This is of course not the full script, just to give you a rough idea.

The thing is: setting up an automatic naming scheme using the date allows me to easily perform all kinds of automated actions.

As to sending of the snapshot... Why would you want a full snapshot replication in the first place? That's only useful if you plan on using the other server as a hot spare of something. Individual files can easily be restored manually using your local snapshots, just look into .zfs/snapshots which is available in the root of each ZFS filesystem.

And when it comes to external backups, I always store my snapshots as images, so, for example:

# zfs send -R zroot/home@<first snapshot> | ssh backup@remote.host "dd of=/opt/backups/server/home_<date stamp>.zfs.

The advantage that I see is that if I have an emergency on my hands then I don't have to wait for the remote server to re-create a whole new stream. I can immediately create one, either over SSH or HTTP (only accessible within my VPN, the idea is that fetch(1) can make a good fallback tool).

Hope this can give you some ideas.
 
Hy ShelLuser, thanks again for your well thought out responses. My setup goes as such with ZAP:
* Server with mirrored zpool and local snapshots as you say
* backup drive connected to a NUC standing by (I could have mounted the drive as altroot on the server but I like this better), snapshots are sent daily to the backup drive on this NUC daily
* Rotating drives is a simple zpool export, swap the drives, zpool import

That's a very interesting idea with images, that can be done incrementally I assume so you're not writing a whole image each time yeah? That may fit my usecase for my zroot zpool, but for my jail pool I think it may be better for me to have just the data stream.

Not sure if this information helps with my current issue of fetching old snapshots that ZAP isn't grabbing though
 
That's a very interesting idea with images, that can be done incrementally I assume so you're not writing a whole image each time yeah?
Absolutely, though I don't use that option myself. But if you use the -i parameter when using # zfs send then you'll create an incremental stream which only contains the changes between the two mentioned snapshots.

And you're right; this doesn't necessarily involve ZAP. I never rely on 3rd party tools myself but always set up my own solutions.
 
Are you not running ZFS on your backup destination? I can’t think of a good use case for saving just the stream otherwise (since you can always create the stream from a dataset anyway, and have the added benefit of being able to access individual files / snapshots if you recv it into a filesystem...)
 
I never rely on 3rd party tools myself but always set up my own solutions.

Yeah I'm starting to want to make that change to something I write so I can be more mentally keen on what I'm doing

Are you not running ZFS on your backup destination?
I do have my backup dest as zfs, 2 separate drives which I will be rotating. Currently ZAP does a send/recv, which is what I prefer because, as you say, I can have the added benefit of accessing individual files/snapshots. It's just there's a month of old snapshots that weren't sent with ZAP so I'm trying to find the right command to get all those old snapshots back without having to do a zfs send -Ri old_snap new_snap | zfs recv...whatever it is, I have it written down hehe, but I hope that conveys my point better
 
I'm not sure why this is even necessary. Normal hard-disks rotate by themselves when in use; that's why they are colloquially known as "spinning rust" in the storage industry. If your disk is not rotating, you have bigger problems than snapshots. And if you are using an SSD, you can just manually turn it around once per day, to equalize the effect of the earth's magnetic field on it.

P.S. :)
 
Back
Top