psy0rz / zfs_autobackup

ZFS autobackup is used to periodicly backup ZFS filesystems to other locations. Easy to use and very reliable.
https://github.com/psy0rz/zfs_autobackup
GNU General Public License v3.0
580 stars 62 forks source link

Issues with Snapshot Format (Timestamp) and Thinning #250

Open norsemangrey opened 5 months ago

norsemangrey commented 5 months ago

I'm having an issue where old snapshots are not thinned when trying to resolve the snapshot format timestamp to a variable before passing it to the zfs-autobackup function.

I'm running multiple snapshot profiles in the same script and for the purpose of managing the snapshots later I would like them all to have the same timestamp in the snapshot name. Thus I'm trying to do something like in the below example, instead of passing timestamp format like this SNAPSHOT_FORMAT="%Y-%m-%dT%H:%M:%S-auto".

This works fine in that the snapshots are created and with the correct name, but thinning of old snapshots no longer works. Is this a bug, and if not is there another way to accomplish what I'm trying to do?

SOURCE_NAME=host-1
SNAPSHOT_FORMAT="$(date +%Y-%m-%dT%H:%M:%S)-auto"

zfs-autobackup SOURCE_NAME \
                    --keep-source=2 \
                    --property-format=snapshot-base:{} \
                    --snapshot-format $SNAPSHOT_FORMAT \
                    --exclude-received \
                    --progress \
                    --debug-output \
                    --verbose

zfs-autobackup SOURCE_NAME \
                    --keep-source=5,1d1w,1w1m \
                    --property-format=snapshot-pri-1:{} \
                    --snapshot-format $SNAPSHOT_FORMAT \
                    --exclude-received \
                    --progress \
                    --debug-output \
                    --verbose
psy0rz commented 5 months ago

look at the original snapshot format, there should be a {} in it, that gets filled in with the backup name automaticly.

norsemangrey commented 5 months ago

I'm probably being dense, but I'm not sure i follow ....

The original snapshot format is this: {}-%Y-%m-%dT%H:%M:%SZ which means my snapshots would be named host-1-<timestamp>. I don't need the snapshot profile- / backup name as part of the snapshot name ... just the timestamp, but I need it to be the same for all profiles in the same script.

psy0rz commented 5 months ago

uuh why are you calling the date command in your snapshot format line? $(date..)

norsemangrey commented 5 months ago

Because I want to resolve the timestamp in the variable before passing it the zfs-autobackup function so that I get the the same timestamp for both snapshot profiles....otherwise there will be some seconds difference ..... It was what I was trying to explain above, but I was probably doing a poor job of it xD

psy0rz commented 3 weeks ago

You're using a fixed string as snapshot "format". This makes it so that zfs-autobackup cant parse the dates and times of the existing snapshots.

If you just want the timestamp, use --snapshot-format=%Y-%m-%dT%H:%M:%SZ

Edwin