Neil A. Wilson
2005-Dec-21 06:41 UTC
[zfs-discuss] Using zfs restore on a single-filesystem pool
I''ve been playing around with ZFS backup and restore, but I''ve run into an odd roadblock in that I can''t seem to restore a backup made from the filesystem that gets created when you make a pool. I can restore backups from subordinate filesystems just fine, but I can''t figure out how to restore the top-level filesystem. For example, say I create a pool backed by a single 100MB file: # dd if=/dev/zero of=/tmp/pool-file bs=1048576 count=100 # zpool create -m /tmp/mypool mypool /tmp/pool-file Then, I put some files in that pool # for I in 1 2 3 4 5 > do > dd if=/dev/zero of=/tmp/mypool/$I bs=1048576 count=5 > done I take a snapshot of the pool and then create a backup from that snapshot: # zfs snapshot mypool at mysnapshot # zfs backup mypool at mysnapshot > /tmp/mysnapshot.backup I now have a valid backup, but I can''t seem to restore it to its original location. If I try to restore it immediately, it fails because the filesystem exists: # zfs restore mypool < /tmp/mysnapshot.backup cannot restore: destination fs mypool already exists So I destroy the filesystem and try again (I have to use -r to get rid of both the filesystem and its snapshot): # zfs destroy -r mypool # zfs restore mypool < /tmp/mysnapshot.backup cannot restore: destination fs mypool already exists I suppose that this is an accurate error message because "zfs list" still shows the mypool filesystem because it''s associated with the mypool pool and you can''t have a pool without a filesystem (at least, not after we got rid of containers). But it looks like it''s preventing me from being able to restore this backup. I can create a new filesystem in the same pool from the backup, like: # zfs restore mypool/filesystem2 < /tmp/mysnapshot.backup but that isn''t what I want because now my files are in /tmp/mypool/filesystem2 rather than in /tmp/mypool like I want them to be. Is there any way to do this without using sub-filesytems? And if not, then can we have containers back so we can have a pool without a filesystem? Oh, and here''s what appears to be a bug in the restore process: if you destroy a pool, get rid of the backing file, remove the directory that it was mounted in, and then try to restore a backup into its former filesystem, then it will still say that the filesystem exists even when there is no remnant of it left: # zfs destroy -r mypool # zpool destroy mypool # rm /tmp/pool-file # rmdir /tmp/mypool # zfs restore mypool < /tmp/mysnapshot.backup cannot restore: destination fs mypool already exists The filesystem certainly does not exist because the pool that had created it is gone along with the backing file and the mountpoint. Neil
Matthew A. Ahrens
2005-Dec-21 20:15 UTC
[zfs-discuss] Re: Using zfs restore on a single-filesystem pool
Yep, the inability to restore into the topmost filesystem is a known defeciency, which we''re working on. http://www.opensolaris.org/jive/message.jspa?messageID=16353#16353 Bug #6358519 ''zfs restore'' can''t restore full backup into topmost filesystem> # zfs restore mypool < /tmp/mysnapshot.backup > cannot restore: destination fs mypool already exists > > The filesystem certainly does not exist because the pool that had > created it is gone along with the backing file and the mountpoint.That looks like an incorrect error message to me, too. Also, ''zfs restore -r pool'' shouldn''t have appeared to work without actually destroying the topmost filesystem. I''ll get bugs filed on these two... Thanks for playing with backup/restore! --matt This message posted from opensolaris.org