using ZFS to migrate data across boxes
By jbeck on Aug 31, 2006
NAME SIZE USED AVAIL CAP HEALTH ALTROOT space 68G 16.6G 51.4G 24% ONLINE -with two file-systems therein:
NAME USED AVAIL REFER MOUNTPOINT space 16.6G 50.3G 99K /export/home space/jbeck 12.2G 50.3G 12.2G /export/home/jbeck space/local 4.25G 50.3G 4.25G /usr/localFirst, on the new box, I ran:
% zpool create space mirror c2d0 c3d0Then:
- I temporarily tweaked
/.ssh/authorized_keysto allow root from the old box to ssh to the new without being prompted for a password (not sure if this step was needed or not)
- Since my desktop is also my mail server, I disabled sendmail to make sure that no mail would come in during the migration
- On the old box I ran:
% zfs snapshot -r space@today % zfs send space/jbeck@today | ssh newbox zfs recv -d space % zfs send space/local@today | ssh newbox zfs recv -d spaceThe two send/recv runs took roughly 30 and 10 minutes respectively, much less than the almost two hours that the back-to-back tar method used to take to do this. Finally, on the new box, I ran:
% zfs set mountpoint=/export/home space % zfs set mountpoint=/usr/local space/local % zfs set sharenfs=on space/jbeck space/localAnd that was it! I'm a happy ZFS user, but note that Matt told me that he is working on an RFE to make the above even simpler:
I'm working on some enhancements to zfs send/recv that will simplify this even further, especially in cases where you have many filesystems, snapshots, or changed properties. In particular, you'll be able to simply do:Nice work, ZFS team.# zfs snapshot -r space@today # zfs send -r -b space@today | ssh newbox zfs recv -p -d newpoolThe "send -b" flag means to send from the beginning. This will send a full stream of the oldest snapshot, and incrementals up to the named snapshot (eg, from @a to @b, from @b to @c, ... @j to @today). This way your new pool will have all of the snapshots from your old pool.
The "send -r" flag means to do this for all the filesystem's descendants as well (in this case, space/jbeck and space/local).
The "recv -p" flag means to preserve locally set properties (in this case, the mountpoint and sharenfs settings).