# ZFS: backup snapshots with tar?



## uisge (Jan 14, 2011)

Hi --

Disclaimer: I migrated two servers to ZFS very recently, thus I do consider myself a newbie regarding ZFS. 

I did read a lot about snapshots and backups in this forum, in Oracle's admin guide, and elsewhere, but I'm still puzzled about statements like "make a snapshot and use that snapshot as starting point for making a backup".

Well, I do understand what *"zfs send*" and "*zfs receive*" is for, and that I may use this functionality for backups. But I did fail miserably in using snapshots[1] as starting points for tarballs[2]. Ok, that can be explained by the fact that snapshots only show modified/removed files, and that ZFS snapshots seem to differ from snapshots in UFS filesystems.

Now my questions:

1) Do I need to clone my snapshots and use those for tarballs?
2) If so, is there an easy way to tar ZFS clones in a recursive manner?
3) If no, what do I misunderstand regarding snapshots/clones?

Thanks in advance.


[1] *zfs set snapdir=visible mypool/mydir*
[2] I'd like to stick with tarballs for the time being, until I'm much more familiar with ZFS and confident to stick with it.


----------



## phoenix (Jan 15, 2011)

uisge said:
			
		

> Well, I do understand what "zfs send" and "zfs receive" is for, and that I may use this functionality for backups. But I did fail miserably in using snapshots[1] as starting points for tarballs[2]. Ok, that can be explained by the fact that snapshots only show modified/removed files, and that ZFS snapshots seem to differ from snapshots in UFS filesystems.



Completely incorrect.  If you do an *ls* or *find* in /path/to/.zfs/snapshot/snapname/, you will see the full filesystem as it was at the time the snapshot was created.

Its difficult to explain how exactly a ZFS snapshot works, internally.  But from the point of view of ls, tar, rsync, find, etc, it includes all files in the filesystem when the snapshot was taken.

Thus, you can use tar, or rsync, or whatever backup software you want, using the /path/to/.zfs/snapshot/<snapname>/ path, exactly the same was that you would use /path/to/



> Do I need to clone my snapshots and use those for tarballs?



No.  Just start your tar command in the snapshot root directory (/path/to/.zfs/snapshot/<snapname>/).


----------



## uisge (Jan 15, 2011)

phoenix said:
			
		

> Its difficult to explain how exactly a ZFS snapshot works, internally.  But from the point of view of ls, tar, rsync, find, etc, it includes all files in the filesystem when the snapshot was taken.
> 
> Thus, you can use tar, or rsync, or whatever backup software you want, using the /path/to/.zfs/snapshot/<snapname>/ path, exactly the same was that you would use /path/to/



Ok, thanks for your helpful feedback. I'm sorry, but I should have tested it more thoroughly before posting :-( I made some silly experiments, had some silly results, became completely confused, and drew silly conclusions ;-)

Well, I will use snapshots as starting points for tarballs for the time being.  

Thanks.


----------

