ZFS Freezing zfs snapshot: do you know any programs that do this?

  • Thread starter Thread starter Deleted member 67440
  • Start date Start date
D

Deleted member 67440

Guest
It is common to use scripts to automate snapshot creation with crontab, with something like
Code:
0 9-20/2 * * * /usr/local/sbin/zfSnap -a 7d tank/d  >/dev/null 2>&1
1 00 * * * /usr/local/sbin/zfSnap -a 60d tank/d >/dev/null 2>&1
30 1 * * * /usr/local/sbin/zfSnap -d
After TOT (7 and 60 days in the example) the snapshots will be deleted (pruned).
But I would like to keep them before they are deleted, to archive all snapshots, "from always to always".

Almost certainly there will be something (maybe in ports) ready, and maybe much refined.

Can anyone give me some advises?
I am writing my own, but it takes longer then expected.

Thank for all reply
 
So you want to create snaphots and never delete them? zfs snap -r <poolname>@snapname will do that.
 
It is common to use scripts to automate snapshot creation with crontab, with something like

0 9-20/2 * * * /usr/local/sbin/zfSnap -a 7d tank/d >/dev/null 2>&1
1 00 * * * /usr/local/sbin/zfSnap -a 60d tank/d >/dev/null 2>&1
30 1 * * * /usr/local/sbin/zfSnap -d

After TOT (7 and 60 days in the example) the snapshots will be deleted (pruned).
But I would like to keep them before they are deleted, to archive all snapshots, "from always to always".
I imagine zfSnap finds snapshots to delete by looking for ones matching its naming pattern. For example I'm using sysutils/zfs-periodic and a typical daily snapshot for my wdssd pool is named wdssd/ROOT@daily-2021-07-26. When I want to keep an automatic snapshot I just rename it to something different.
 
I want to archive the snapshots just before delete it.
In this example 2-hours snapshot are created, and retained for 7d (seven days).
After that the older (>7) will be deleted, it is a well known, widespread mechanism


Code:
/tank/d@2021-07-26_09.00.00--7d
/tank/d@2021-07-26_11.00.00--7d
/tank/d@2021-07-26_13.00.00--7d
/tank/d@2021-07-26_15.00.00--7d
/tank/d@2021-07-26_17.00.00--7d
/tank/d@2021-07-26_19.00.00--7d
/tank/d@2021-07-27_09.00.00--7d
/tank/d@2021-07-27_11.00.00--7d
/tank/d@2021-07-27_13.00.00--7d
/tank/d@2021-07-27_15.00.00--7d
/tank/d@2021-07-27_17.00.00--7d
/tank/d@2021-07-27_19.00.00--7d
/tank/d@2021-07-28_09.00.00--7d
/tank/d@2021-07-28_11.00.00--7d
/tank/d@2021-07-28_13.00.00--7d
/tank/d@2021-07-28_15.00.00--7d
/tank/d@2021-07-28_17.00.00--7d
/tank/d@2021-07-28_19.00.00--7d
/tank/d@2021-07-29_09.00.00--7d
/tank/d@2021-07-29_11.00.00--7d
/tank/d@2021-07-29_13.00.00--7d
/tank/d@2021-07-29_15.00.00--7d
/tank/d@2021-07-29_17.00.00--7d
/tank/d@2021-07-29_19.00.00--7d
/tank/d@2021-07-30_09.00.00--7d
/tank/d@2021-07-30_11.00.00--7d
/tank/d@2021-07-30_13.00.00--7d
/tank/d@2021-07-30_15.00.00--7d
/tank/d@2021-07-30_17.00.00--7d
/tank/d@2021-07-30_19.00.00--7d
/tank/d@2021-07-31_09.00.00--7d
/tank/d@2021-07-31_11.00.00--7d
/tank/d@2021-07-31_13.00.00--7d
/tank/d@2021-07-31_15.00.00--7d
/tank/d@2021-07-31_17.00.00--7d
/tank/d@2021-07-31_19.00.00--7d
/tank/d@2021-08-01_09.00.00--7d
/tank/d@2021-08-01_11.00.00--7d
/tank/d@2021-08-01_13.00.00--7d
/tank/d@2021-08-01_15.00.00--7d
/tank/d@2021-08-01_17.00.00--7d
/tank/d@2021-08-01_19.00.00--7d
/tank/d@2021-08-02_09.00.00--7d
/tank/d@2021-08-02_11.00.00--7d
/tank/d@2021-08-02_13.00.00--7d
Tomorrow those snapshots will be erased
Code:
/tank/d@2021-07-26_09.00.00--7d
/tank/d@2021-07-26_11.00.00--7d
/tank/d@2021-07-26_13.00.00--7d
/tank/d@2021-07-26_15.00.00--7d
/tank/d@2021-07-26_17.00.00--7d
/tank/d@2021-07-26_19.00.00--7d

With my little software I can archive all the data in those snapshot.
So, tomorrow, after the crontabbe-prune runs, the deleted snapshot will be (forever) in my archive.
If in 2022 I want to get back data @2021-07-26_17.00.00 I can, even if the snapshot is deleted long time before.


However, I have a technical limitation: the snapshots must be monotonous and growing.
If I archive the snapshots of July 26th, 27th, 28th (in that order) there is no problem. And after that 29, 30, 1 aug ..., that's OK (monotono crescente).

Instead, I CANNOT do it in the sequence (let's say) July 26, 28, 27.
Why? Trust me (it is long to explain).

Perhaps, however, there are software already made that can store entire snapshots (possibly hundreds of GB each), in an arbitrary sequence (26, 28, 27)

Just to be clear it is not realistic to use something like rar (or tar, or 7z, or lzturbo, or zstd or whatever)

Code:
rar a /myfreezedsnapshot.rar /tank/d/.zfs/snapshot/2021-07-26_09.00.00--7d /tank/d/.zfs/snapshot/2021-07-26_11.00.00--7d /tank/d/.zfs/snapshot/2021-07-26_13.00.00--7d /tank/d/.zfs/snapshot/2021-07-26_15.00.00--7d /tank/d/.zfs/snapshot/2021-07-26_17.00.00--7d /tank/d/.zfs/snapshot/2021-07-26_19.00.00--7d

A zfs send automation script (to turn snapshots into files via redirection) will be fine, BUT (AFAIK) would not allow to restore a single file from a snapshot without restoring "the whole world".
In other words: in 2022 (for example) I want to get back /tank/d/.zfs/snapshot/2021-07-26_11.00.00/usr/local/etc/smb4.conf
 
Back
Top