Backing up .zfs

Status
Not open for further replies.

doglover

Dabbler
Joined
Nov 22, 2012
Messages
44
Hello. I thought that .zfs snapshots only held changes. The listing of snapshots showed many with a use of zero or almost zero, which I thought supported that notion. However, if I use rsync to back up one of the supposedly empty or almost empty directories, it looks like it is backing up everything. Can anyone please explain?
Thanks
IMF
 

jgreco

Resident Grinch
Joined
May 29, 2011
Messages
18,680
For the purposes of computing space requirements, you can think about it as ZFS snapshots only holding changes, yes.

What directory or directories are you referring to? If you're thinking of the snapshot directories under ".zfs", those hold an image of the filesystem at the time of the snapshot - not just a list of changed files.

Your question seems to imply maybe you think only changed files would show up there. How the heck would that work in a meaningful way? Try implementing it in your head.

If you added a file, fine, it shows up there. Not too hard.

If you deleted a file, um, how do you denote that?

If you changed the entire contents of a file, fine, it shows up there.

If you changed the first byte of a 1TB file, do you show the entire file? A 1 byte file? etc?

And if you're trying to use the snapshot, and no files have changed, how useful is an empty directory? Do you really propose that someone has to take the union of tens or hundreds or thousands of snapshots in order to find the file they want to recover?

Those snapshot directories are going to contain a representation of the entire filesystem. If you try to rsync them, you'll be able to read all the contents of the filesystem as they appeared at that time. It's supposed to do that.
 

ben

FreeNAS GUI Developer
Joined
May 24, 2011
Messages
373
The reason it lists snapshot size the way it does has to do with how ZFS snapshots work. Each snapshot points to all the blocks of the filesystem that were in use at the time. If you make no changes, the snapshot takes up no ADDITIONAL space as compared to the live filesystem, so the cost in terms of capacity of preserving that snapshot is zero. However, if you delete a file, the snapshot is now the ONLY thing keeping the blocks that file was on from being re-used, so the snapshot will list that as its capacity usage.
 

fracai

Guru
Joined
Aug 22, 2012
Messages
1,212
Also, if you were to create a large file, make two snapshots, and then delete the file, both snapshots will list 0 bytes used. Basically, each snapshot lists how much data is unique to that snapshot. If a snapshot contains data that is only referenced in other snapshots, it won't be counted towards the space used. Anytime you delete a snapshot, it's likely that the bytes used by other snapshots will change.
 
Status
Not open for further replies.
Top