# Recursively changing ZFS mount points



## Julf (Dec 1, 2019)

Scratching my head again. I want to do regular snapshots of my system on a separate backup server (in a different location). I run the following on the backup system:


```
ssh root@SERVER zfs snapshot -r zroot@$DATE
ssh root@SERVER zfs send -R zroot@$DATE | zfs recv -uvdF zroot/backup
```

The copy is fine, and the stuff shows up:


```
$ zfs list
NAME                                  USED  AVAIL  REFER  MOUNTPOINT
zroot                                8.52T  5.09T   128K  /zroot
zroot/ROOT                            933M  5.09T   128K  none
zroot/ROOT/default                    933M  5.09T   933M  /
zroot/backup                         8.52T  5.09T   128K  /zroot
zroot/backup/ROOT                    8.99G  5.09T   128K  none
zroot/backup/ROOT/default            8.99G  5.09T  7.01G  /
zroot/backup/home                    7.46T  5.09T   128K  /zroot/home
zroot/backup/home/storage            7.46T  5.09T  7.04T  /usr/home/storage
zroot/backup/home/storage/backup      403G  5.09T   355G  /usr/home/storage/backup
zroot/backup/tmp                     3.26G  5.09T  3.26G  /tmp
zroot/backup/usr                     1.05T  5.09T   128K  /usr
zroot/backup/usr/home                1.05T  5.09T  1.05T  /usr/home
zroot/backup/usr/home/samba           256K  5.09T   128K  /usr/home/samba
zroot/backup/usr/home/samba/storage   128K  5.09T   128K  /usr/home/samba/storage
zroot/backup/usr/ports               1.27G  5.09T  1.27G  /usr/ports
zroot/backup/usr/src                  128K  5.09T   128K  /usr/src
zroot/backup/var                     3.64M  5.09T   128K  /var
zroot/backup/var/audit                128K  5.09T   128K  /var/audit
zroot/backup/var/crash                128K  5.09T   128K  /var/crash
zroot/backup/var/log                 2.79M  5.09T  1.79M  /var/log
zroot/backup/var/mail                 279K  5.09T   163K  /var/mail
zroot/backup/var/tmp                  209K  5.09T   128K  /var/tmp
zroot/tmp                             128K  5.09T   128K  /tmp
zroot/usr                             727K  5.09T   128K  /usr
zroot/usr/home                        343K  5.09T   215K  /usr/home
zroot/usr/home/backup                 128K  5.09T   128K  /usr/home/backup
zroot/usr/ports                       128K  5.09T   128K  /usr/ports
zroot/usr/src                         128K  5.09T   128K  /usr/src
zroot/var                             947K  5.09T   128K  /var
zroot/var/audit                       128K  5.09T   128K  /var/audit
zroot/var/crash                       128K  5.09T   128K  /var/crash
zroot/var/log                         308K  5.09T   308K  /var/log
zroot/var/mail                        128K  5.09T   128K  /var/mail
zroot/var/tmp                         128K  5.09T   128K  /var/tmp
```

So now if I want to find/restore a file from the copied snapshot, I have to mount it. I want to mount it on /mnt/backups. I thought this would work:


```
$ sudo zfs set mountpoint=/mnt/backups zroot/backup
```

but the result is not what I expected:


```
$ zfs list
NAME                                  USED  AVAIL  REFER  MOUNTPOINT
zroot                                8.52T  5.09T   128K  /zroot
zroot/ROOT                            933M  5.09T   128K  none
zroot/ROOT/default                    933M  5.09T   933M  /
zroot/backup                         8.52T  5.09T   128K  /mnt/backups
zroot/backup/ROOT                    8.99G  5.09T   128K  none
zroot/backup/ROOT/default            8.99G  5.09T  7.01G  /
zroot/backup/home                    7.46T  5.09T   128K  /mnt/backups/home
zroot/backup/home/storage            7.46T  5.09T  7.04T  /usr/home/storage
zroot/backup/home/storage/backup      403G  5.09T   355G  /usr/home/storage/backup
zroot/backup/tmp                     3.26G  5.09T  3.26G  /tmp
zroot/backup/usr                     1.05T  5.09T   128K  /usr
zroot/backup/usr/home                1.05T  5.09T  1.05T  /usr/home
zroot/backup/usr/home/samba           256K  5.09T   128K  /usr/home/samba
zroot/backup/usr/home/samba/storage   128K  5.09T   128K  /usr/home/samba/storage
zroot/backup/usr/ports               1.27G  5.09T  1.27G  /usr/ports
zroot/backup/usr/src                  128K  5.09T   128K  /usr/src
zroot/backup/var                     3.64M  5.09T   128K  /var
zroot/backup/var/audit                128K  5.09T   128K  /var/audit
zroot/backup/var/crash                128K  5.09T   128K  /var/crash
zroot/backup/var/log                 2.79M  5.09T  1.79M  /var/log
zroot/backup/var/mail                 279K  5.09T   163K  /var/mail
zroot/backup/var/tmp                  209K  5.09T   128K  /var/tmp
zroot/tmp                             128K  5.09T   128K  /tmp
zroot/usr                             732K  5.09T   128K  /usr
zroot/usr/home                        349K  5.09T   221K  /usr/home
zroot/usr/home/backup                 128K  5.09T   128K  /usr/home/backup
zroot/usr/ports                       128K  5.09T   128K  /usr/ports
zroot/usr/src                         128K  5.09T   128K  /usr/src
zroot/var                             953K  5.09T   128K  /var
zroot/var/audit                       128K  5.09T   128K  /var/audit
zroot/var/crash                       128K  5.09T   128K  /var/crash
zroot/var/log                         314K  5.09T   314K  /var/log
zroot/var/mail                        128K  5.09T   128K  /var/mail
zroot/var/tmp                         128K  5.09T   128K  /var/tmp
```

So the mount point for zroot/backup and zroot/backup/home changed, but not the others. I would have expected either only zroot/backup to change, or all the ones under it. 

What am I missing, and how do I recursively change the mountpoints of everything under zroot/backup?


----------

