allanjude / zxfer

A continuation of development on zxfer, a popular script for managing ZFS snapshot replication
BSD 2-Clause "Simplified" License
123 stars 40 forks source link

Running zxfer while deleting snapshots breaks the grandfather logic. #30

Open Crest opened 7 years ago

Crest commented 7 years ago

I tried to run zxfer(8) a during the last minute of an hour and have an hourly cronjob destroying old snapshots. This triggered a race condition in zxfer(8) causing it to return the days since epoch as age of the snapshot.

Checking grandfather status of all snapshots marked for deletion...
cannot open 'XXXroot/backup/jails/YYY@hourly-2016-10-12-21': dataset does not exist
cannot open 'XXXroot/backup/jails/YYY@hourly-2016-10-12-21': dataset does not exist
Error: On the destination there is a snapshot marked for destruction
by zxfer that is protected by the use of the "grandfather
protection" option, -g.

You have set grandfather protection at 376 days.
Snapshot name: XXXroot/backup/jails/YYY@hourly-2016-10-12-21
Snapshot age : 17088 days old
Snapshot date: .
Your current system date: Fr. 14 Okt. 2016 11:03:29 CEST.

Either amend/remove option g, fix your system date, or manually
destroy the offending snapshot. Also double check that your
snapshot management tool isn't erroneously deleting source snapshots.
Note that for option g to work correctly, you should set it just
above a number of days that will preclude "father" snapshots from
being encountered.

usage:
     zxfer [-dFnPsUv] [-k | -e] [-b | -B] {-N path/to/src | -R path/to/src}
           [-m [c FMRI|pattern[ FMRI|pattern]...]]] [-O user@host]
           [-D 'progress dialog options'] [-I properties,to,ignore]
           [-T user@host] [-o option1=value1,option2=value2...] [-g days]
           destination
     zxfer {-S} [-dilpPnv] [-k | -e] [-b | -B] [-f /path/to/rsfile]
           {-R /path/to/src1,path/to/src2... | -N /path/to/src1,path/to/src2...}
           [-o option1=value1,option2=value2...] [-E pattern] [-L value]
           [-u snapshot] destination
     zxfer [-h]

           Where destination is a ZFS filesystem e.g.  poolname/fsname

zxfer has a man page that explains each of the options in detail, along with
usage examples. To access the man page, type:
$ man zxfer