# ZFS backup FreeBSD10



## fred974 (Jan 22, 2014)

Hello,

I just install FreeBSD 10 on a new test system and I have a very basic question.
Which of thetwo syntax bellow should I be using to perform a clean snapshopt of the system before I start doing anything to it?


```
zfs snapshot -r zroot@bare-install
```
or

```
zfs snapshot zroot@bare-install
```

Thank you
Fred


----------



## SirDice (Jan 22, 2014)

They both make a snapshot of the zroot filesystem. The addition of -r simply tells it to also make snapshots of the filesystems below zroot, i.e. zroot/data.


----------



## fred974 (Jan 22, 2014)

So if I don't include the -r, I'll still be able to recover data in zroot/home/someuser?


----------



## SirDice (Jan 22, 2014)

fred974 said:
			
		

> So if I don't include the -r, I'll still be able to recover data in zroot/home/someuser?


Only if you actually made a snapshot of zroot/home/someuser. The command `zfs snapshot zroot@bare-install` creates a snapshot of the zroot filesystem and nothing else. It will not snapshot zroot/home and zroot/home/someuser. If you want to snapshot those either do them one by one or do a recursive snapshot with -r.


----------



## usdmatt (Jan 22, 2014)

> The command zfs snapshot zroot@bare-install creates a snapshot of the zroot filesystem and nothing else. It will not snapshot zroot/home and zroot/home/someuser.



Just to be clear, if you only have one ZFS filesystem, like the example below, you only need to create a snapshot of that filesystem. If /home and /home/someuser are just directories, they will be part of the snapshot.


```
# zfs list
NAME               USED  AVAIL  REFER  MOUNTPOINT
zroot               1.35G  12.3G    31K  legacy
#
# zfs snapshot zroot@bare-install
```

Snapshots are done on a per-filesystem level ('dataset' in ZFS terminology) so if you have any sub-datasets, such as in the example below, you will need to snapshot them separately or use `-r`


```
# zfs list
NAME               USED  AVAIL  REFER  MOUNTPOINT
zroot               1.35G  12.3G    31K  legacy
zroot/home     1.35G  12.3G    31K  /home
#
# zfs snapshot zroot@bare-install
```

The snapshot of zroot above would not include any data inside the zroot/home dataset. You'd have to snapshot both:


```
# zfs snapshot zroot@bare-install
# zfs snapshot zroot/home@bare-install
or better -
# zfs snapshot -r zroot@bare-install
```


----------



## fred974 (Jan 23, 2014)

OK thank you for the clarification.
I have only one ZFS filesystem called ZROOT and /home is a directory in my filesystem.
So from what I understand the syntax below should be OK as a full backup.

```
zfs snapshot zroot@bare-install
```


----------



## SirDice (Jan 23, 2014)

In that case, yes, that should be enough.


----------



## fred974 (Jan 23, 2014)

Thank you @SirDice for the confirmation


----------

