# ZFS Snapshots



## bsus (Sep 17, 2011)

Hi,
I have an issue with my ZFS snapshots

```
freebsd ~ # zpool status
  pool: storage
 state: ONLINE
 scrub: none requested
config:

        NAME        STATE     READ WRITE CKSUM
        storage     ONLINE       0     0     0
          raidz1    ONLINE       0     0     0
            ad6     ONLINE       0     0     0
            ad8     ONLINE       0     0     0
            ad10    ONLINE       0     0     0
            ad12    ONLINE       0     0     0
            ad14    ONLINE       0     0     0

errors: No known data errors
freebsd ~ # zfs snapshot /usr/home@17.09.2011
cannot snapshot '/usr/home@17.09.2011': leading slash in name
freebsd ~ # zfs snapshot storage/home@17.09.2011
freebsd ~ # zfs list
NAME           USED  AVAIL  REFER  MOUNTPOINT
storage       1.32T  5.81T   192K  legacy
storage/home  1.32T  5.81T  1.32T  legacy
```

As you see the problem is that snapshots aren't getting saved properly. I think this is because I mount zfs over fstab and not over zfs itself. So I also don't have a /storage dir. Do I have to disable zfs over fstab or is there a solution?

Regards


----------



## rusty (Sep 17, 2011)

What's the output of
`$ zfs list -t snapshot`


----------



## bsus (Sep 17, 2011)

```
zfs list -t snapshot
NAME                      USED  AVAIL  REFER  MOUNTPOINT
storage@10.09.11             0      -   192K  -
storage/home@09.09.11     452M      -  1.32T  -
storage/home@10.09.11     363M      -  1.32T  -
storage/home@17.09.2011   294K      -  1.32T  -
```
Ah there they are.
Thanks, for this 


I still have another question:
As example there is a file which I had before 2 weeks and I have a snapshot for this date.
Now I that file is deleted and I want it back. Do I know have to:
Rollback the 2 week old snapshot, recover the file and rollback to the actual snapshot?


----------



## graudeejs (Sep 17, 2011)

`$ cp /some/zfs/mountpoint/.zfs/snapshot/some_snapshot_name/path/to/deleted/file /some/zfs/mountpoint/path/to/deleted/file`


----------



## graudeejs (Sep 17, 2011)

If you rollback, then any newer snapshots, than the one, that you rolled back, will be deleted (it will warn you, and ask to use some -r or -R [don't remember] switch, to really roll back)


----------



## bsus (Sep 17, 2011)

Ok, so such a problem would be a more difficult operation.

hmm and is there anyway to rollback seperatly?
So you "load" the snapshot in an extra dir where you can read the files of the snapshot and you can easily copy the files of this dir to real data?

Regards


----------



## gkontos (Sep 17, 2011)

@bsus,

If you roll back a snapshot all of the files created / altered after the snapshot was taken will be lost.
So, that leaves you with 2 ways to grab individual files or folders from these snapshots without rolling them back.

1) Locate the file inside the snapshot by going into the .zfs directory
2) Clone the snapshot to a different location and then find the files you want

[CMD=""]#zfs clone storage/home@17.09.2011 storage/home/newhome[/CMD]

Hope this helps,

George


----------



## bsus (Sep 17, 2011)

@gkontos

Good! 

One last question. When I am mounting ZFS over fstab, where do I find the .zfs-dir?
/storage/home/.zfs doesn't exist anymore!!

Thanks for youre help,
Regards


----------



## gkontos (Sep 17, 2011)

bsus said:
			
		

> @gkontos
> 
> Good!
> 
> ...



I am not sure about this but have you tried going into the directory and then issue a

[CMD=""]# cd .zfs[/CMD]

Also what ZFS version are you using ?


----------



## graudeejs (Sep 17, 2011)

gkontos said:
			
		

> I am not sure about this but have you tried going into the directory and then issue a
> 
> [CMD=""]# cd .zfs[/CMD]
> 
> Also what ZFS version are you using ?



by default .zfs is invisible
To make it visible set *snapdir=visible*
`# zfs set snapdir=visible zpool/zfilesystem`


----------



## gkontos (Sep 17, 2011)

graudeejs said:
			
		

> by default .zfs is invisible
> To make it visible set *snapdir=visible*
> `# zfs set snapdir=visible zpool/zfilesystem`


I know that but I can still access it  (I have it invisible also)


----------



## bsus (Sep 17, 2011)

Thanks for the quick answers.

So there two ways to access directly the snapshots when using fstab
1.) Go to the zfs dir (by me /usr/home) and use *cd .zfs* (gkontos)
2.) 
	
	



```
zfs set snapdir=visible storage/home
```
 (graudeejs)

Now I see this with accessing the snaps directly - thats how I imagined 
Now I could share the snaps over network and theres no need for someone who logs on with the terminal just to "rescue" a file 

Regards


----------



## graudeejs (Sep 17, 2011)

.zfs in root of zfs file sytem.
For example if you have tank/some/zfs and you mount tank/some/zfs to /some/zfs, then .zfs dir will be in /some/zfs/.zfs


----------

