Solved zfs snapshot - exclude directory

Hi,

At the moment I have a script that do differential backup ....
I keep 30 days worth of snapshot on the server but also send all dailly snapshot offsite..
When I run zfs snapshot -r zroot@-2017-03-29 I get a copy of everything
Code:
NAME                                                           USED  AVAIL  REFER  MOUNTPOINT
zroot@-2017-03-29                                                 0      -   192K  -
zroot/ROOT@-2017-03-29                                            0      -   192K  -
zroot/ROOT/default@-2017-03-29                                 175M      -   992M  -
zroot/tmp@-2017-03-29                                          176K      -   288K  -
zroot/usr@-2017-03-29                                             0      -   192K  -
zroot/usr/home@-2017-03-29                                     160K      -   376K  -
zroot/usr/jails@-2017-03-29                                    735K      -  4.77G  -
zroot/usr/jails/mariadb@-2017-03-29                            400K      -   120M  -
zroot/usr/jails/mariadb/var@-2017-03-29                        759K      -  26.7M  -
zroot/usr/jails/mariadb/var/db@-2017-03-29                    1.93M      -  31.4M  -
zroot/usr/jails/mariadb/var/db/mysql@-2017-03-29               408K      -   402M  -
zroot/usr/jails/mariadb/var/db/mysql-innodb@-2017-03-29       5.26M      -  76.8M  -
zroot/usr/jails/mariadb/var/db/mysql-innodb-logs@-2017-03-29  3.56M      -  96.2M  -
zroot/usr/jails/nginx@-2017-03-29                             3.11M      -  53.3M  -
zroot/usr/jails/ns1@-2017-03-29                               2.79M      -  88.9M  -
zroot/usr/jails/postfixserver@-2017-03-29                          137M      -  13.8G  -
zroot/usr/jails/wordpress_tpl@-2017-03-29                     7.03M      -  1.31G  -
zroot/usr/ports@-2017-03-29                                    197M      -  1.31G  -
zroot/usr/src@-2017-03-29                                         0      -   957M  -
zroot/var@-2017-03-29                                             0      -   192K  -
zroot/var/audit@-2017-03-29                                       0      -   192K  -
zroot/var/crash@-2017-03-29                                       0      -   192K  -
zroot/var/log@-2017-03-29                                      655K      -   855K  -
zroot/var/mail@-2017-03-29                                     160K      -   400K  -
zroot/var/tmp@-2017-03-29                                      128K      -   192K  -
The whole idea is that if production server goes down, I can take the backup server to the DC and swap them over with minimal downtime..

However, things like
zroot/usr/ports
,
zroot/usr/src
,
zroot/var/tmp are using a lot of disk space over the 30 day period and they are not really needed or restore service...

SO question:
1. How can I exclude directory from snapshot
2. Should I not try to exclude them?

Thank you
 
Instead of using -r, you could create the snapshots specifically for only the datasets you're interested in.

ADDED: The downsides I can think of are that 1) you now have to run multiple commands and 2) snapshots won't be created as one atomic operation.
 
ADDED: The downsides I can think of are that 1) you now have to run multiple commands and 2) snapshots won't be created as one atomic operation.

One obvious solution would be to take a recursive snapshot each day but have the script then delete the new snapshot on any dataset you want to exclude.

On my system I just have a script that takes snapshots individually based on a per-dataset net.mydomain:snap setting, which also contains the retention settings for that dataset. I have no need for every snapshot to be atomic.
 
Create a separate dataset tree for things you don't want included in snapshots/backups, and move the datasets there.
 
Back
Top