Migrating from ZFS with snapshots

I have an existing ZFS pool with a few years’ worth of snapshots. I am building out a new pool and am about 80% convinced that I will be going with Rockstor this time around. However, I would love to retain my historical snapshots. Is there a way to migrate snapshots to btrfs?

My guess is that there is not an existing tool that just does this, but I wonder if the necessary hooks are there to do it manually (or rather, by script). I am thinking something along the lines of:

  1. On old server (FreeNAS), mount a read-only copy of snapshot k.
  2. On new server (Rockstor), perform an rsync from snapshot k on the old server to local.
  3. Perform a snapshot on Rockstor (and ideally set that snapshot’s timestamp to match snapshot k from FreeNAS).
  4. Repeat for snapshot k+1.

Does that make sense? Has anyone thought about tackling this?

Hi @Coda and welcome to Rockstor Community:

Currently for aught I know there’s not a zfs-btrfs snapshots migrating tool, so if you just need to migrate your data right way is rsync plus an initial snapshot.
If instead you want to migrate all snapshots (does this make sense to replicate all old snapshots?), I’m not sure about that, but probably it’ll require a long time

Flyer

For most of my media etc., I can get by with the just the data, but I have a couple volumes with documents, work stuff, photos, and financial information for which I never expire old monthly snapshots. My intent is to keep them forever. The bulk of my data (the media) I really just want to protect against single-device-failure and bit-rot, but the data with historical snapshots is my “mission-critical, non-reproducible” data; currently those snapshots are backed-up off-site with ZFS send-receive.

If I stay within the ZFS ecosystem, I can send-receive to new pools and machines when I upgrade, retaining those snapshots. If I switch to btrfs, I’d really like a way to get those historical snapshots into btrfs snapshots. Otherwise I have to leave my old pool of disks intact and can’t re-use them in Rockstor.

Does what I want to do at least sound possible manually? It would take approximately 3.61 billion years to do by hand, but anything that can be done manually can ultimately be scripted :wink:

1 Like

Ok @Coda , you’re a cool and crazy guy so we can be good friends! :smile:

I don’t think it’s possible to migrate zfs snapshots to btrfs snapshots because zfs and btrfs have a different structure (hash tables vs B-trees), so you need a tricky solution.

Possible one : move to first zfs snapshot, rsync to btrfs, snapshot on btrfs, back to zfs and move to first+1 snapshot, rsync to btrfs, snapshot on btrfs and so till the end of the world!

PROS:

  • Welcome to Rockstor Land! :grin:
  • After 3.61 billion years (depending on your data) you get a “perfect” copy of your data
  • You can script it (and this seems to be so crazy probably i would try to do it too eheheheh :joy: or at least give you help :slight_smile: )

CONS:

  • The “perfect” copy of your data will have all your snapshots, but with a wrong timing (first will be on now, next on now+x sec, etc) so you won’t have a good time reference for rollbacks
  • Depending on your data size and snapshots number your disks will suffer like a lobster in boiling water :scream:

EDIT on CONS: your newly created snapshots won’t reflect zfs snapshots time, but with the right rsync your files obviously will preserve the right time

@phillxnet - @suman any suggestion?? IMO this can be interesting for everyone migrating (free)nas(4free) to Rockstor

Flyer

1 Like

OK, so it sounds like this is possible in principal, with some caveats.

There’s no way to poke the snapshot timestamp in btrfs after the fact, like you can do with files using touch? One workaround would be to add an empty placeholder file at the root of the migrated volume and, after rsync from the old ZFS snapshot to btrfs, set the file name to the ZFS snapshot’s timestamp. Are you able to e.g. “find file matching pattern in snapshots” with btrfs?

Another alternative would be to take those critical data sets with historical snapshots and do a permanent archive, either on a couple of off-site drives or Glacier or something; then if I want to go back further than the transition to Rockstor, I pull up the archival snapshots. That is less elegant, but it works.

On the fly answer (time to go home, escaping from office :stuck_out_tongue:) : not sure about touch, but a btrfs/zfs snapshot is not just a “filename” or a file atime mtime etc etc, it’ s a little more complex (metadata etc etc).
Obviously with some coding you can define your snapshot name (so you can match with the old zfs): you’re right and it is so easy I didn’t think about this xD

Flyer

Yes I know, I’m using touch as a reference. As in, " is to btrfs snapshots as touch is to file atime, mtime, etc.".

My suspicion is that the root node for snapshots are immutable, thus is not possible. I may check the btrfs mailing list too, since this is pretty low-level in the filesystem itself and not really a Rockstor-specific thing.

I’m almost sure you can try the “tricky way” of rsync from a snapshot, snap on btrfs, rsync etc etc - note: depending on the number of snapshots you want to reproduce and total files size it can be a long and hard way, also with a script, more because of rsync rather than snapshots.

Flyer