Skip to content

Allow configuring the date and time formatting used in snapshot names#39

Open
chazapis wants to merge 2 commits into
yboetz:masterfrom
chazapis:datetime-formatting
Open

Allow configuring the date and time formatting used in snapshot names#39
chazapis wants to merge 2 commits into
yboetz:masterfrom
chazapis:datetime-formatting

Conversation

@chazapis

@chazapis chazapis commented Jul 16, 2019

Copy link
Copy Markdown

Two new, optional parameters in the configuration file date_format and time_format allow you to override the default strftime() values of %Y-%m-%d and %H:%M:%S respectively. This change may be really helpful if you want to expose snapshots over the network. Samba will "mangle" the names of files or directories containing the ":" character, as many operating systems do not allow it (in fact, Mac OS won't even show a directory containing a colon character).

While at it, the prefix used for snapshots (currently "pyznap"), has also been made configurable.

Note that the changes are not "backwards compatible". The snapshot prefix, as well as date and time formatting are part of pyznap's snapshot management code, so it will ignore snapshots taken with different values of the variables.

@chazapis chazapis force-pushed the datetime-formatting branch from 58abfda to 0ac0255 Compare July 16, 2019 12:29
@yboetz

yboetz commented Jul 16, 2019

Copy link
Copy Markdown
Owner

I'll have to look into this a bit deeper on the weekend, to make sure it doesn't break anything. I'm a bit worried about backwards compatibility as you said, e.g. if at some point you change the format (but not the prefix), then pyznap will fail as it cannot match the date/time of old snaps anymore.

@chazapis

Copy link
Copy Markdown
Author

Yes, I agree that the backwards compatibility is concerning, but this is really useful for new deployments. For that reason, I have not changed the sample configuration file. As it is now, the new options are "undocumented features".

@yboetz

yboetz commented Aug 22, 2019

Copy link
Copy Markdown
Owner

Sorry for not getting back to you earlier, I only found time to work on pyznap again this week. I did a few tests with different prefixes and date/time formats, but I'm not convinced yet. Something can go wrong quickly if you choose other date/time formats, e.g. there cannot be any '_' in the formats. And you also always want hours, minutes and seconds in the time format, to accurately take snapshots. I need to think about how to make this a bit more robust.

@DeViLRuNNeR-dev

Copy link
Copy Markdown

I have done some testing myself and it turns out we can't use Windows Shadow Copies on Samba due to the naming of these snapshots. There is not option in SAMBA to catch the snapshottype (hourly, frequent) on the end of the snapshot name.

Does anybody know how we can change the code to put the snapshottype in front of the data/time?

@ShaRose

ShaRose commented Nov 30, 2019

Copy link
Copy Markdown

Hilariously late, but at least for verifying if a format would work you can simply loop and check if the needed parts are in the format string passed. Ditto for sanity checking invalid characters.

As a far more intrusive option, you could simply not include what kind of snapshot it is in the snapshot, only take one for all schedules, and include what schedules a snapshot counts for in a user property on the snapshot when taking it, and then use zfs set to expire options as needed.

For example,

zfs snap -o com.github.yboetz.pyznap:snapshotplans=frequent,hourly,daily,weekly themis-pool@pyznap_2019-11-29_22:00:00

and then as there are enough frequents, but it still counts as a daily / hourly / etc snapshot,

zfs set com.github.yboetz.pyznap:snapshotplans=hourly,daily,weekly themis-pool@pyznap_2019-11-29_22:00:00

You'd be able to see all snapshots in samba, and you'd be able to lower the number of total snapshots on the system considerably which would probably speed up almost everything fairly considerably (Fewer snapshots, so less time listing and sending: less made, so less time on actually taking them: expiring frequents now simply modifies metadata, but not the snapshot itself or the guid).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants