zfsonlinux / zfs-auto-snapshot

ZFS Automatic Snapshot Service for Linux
GNU General Public License v2.0
848 stars 244 forks source link

date in snapshot #74

Open ryanmasse opened 6 years ago

ryanmasse commented 6 years ago

I'm assuming it's recording the date as UTC? Is there any way of switching it to reflect the local time?

storage/mysqllogs@zfs-auto-snap_frequent-2017-10-20-1600 0 - 40.7K - root@db1:~# date Fri Oct 20 12:14:47 EDT 2017

dpendolino commented 6 years ago

Same here on Arch Linux running:

spl-linux 0.7.3.4.13.9.1-1
spl-utils-common 0.7.3-1
zfs-auto-snapshot-git 1:1.2.1.1.r2.049e966-1
zfs-linux 0.7.3.4.13.9.1-1
zfs-utils-common 0.7.3-1
$ sudo zfs list -t snapshot
NAME                                    USED  AVAIL  REFER  MOUNTPOINT
tank@znap_2017-10-31-1458_hourly        256K      -   439G  -
tank@znap_2017-10-31-1502_hourly         96K      -   445G  -
tank/test@znap_2017-10-31-1502_hourly     0B      -    96K  -
$ date
Tue Oct 31 11:03:59 EDT 2017
4oo4 commented 6 years ago

Here's the culprit:

https://github.com/zfsonlinux/zfs-auto-snapshot/blob/277287f8241b069fc030267f1899837be4e6f77b/src/zfs-auto-snapshot.sh#L537

To get it in your locale, just remove the --utc part. I feel like UTC should be an option for the timestamp, instead of the default?

rlaager commented 6 years ago

I think it makes sense as the default. UTC is unambiguous and monotonic. Due to DST, snapshot names in local time do not always order chronologically if sorted lexographically. And if you are unlucky, snapshotting can fail due to a duplicated name.

If UTC is already the default (which I didn’t verify), then changing it means breaking backwards compatibility.

sjau commented 6 years ago

I agree with rlaager - UTC makes things unambiguous (ok, it won't help if you mess up server/computer time)

ryanmasse commented 6 years ago

what if it were configurable? :)

4oo4 commented 6 years ago

@slopokeit Yeah, that's kinda where I was heading. @rlaager makes a good point to keep UTC the default, but it would be handy to have it configurable rather than having to edit the script.

jbnance commented 6 years ago

The default was local TZ until: https://github.com/zfsonlinux/zfs-auto-snapshot/pull/18

Strangely the comment thread mentions that a program option should be added to preserve backwards compatibility but the pull was merged without it.

jbnance commented 6 years ago

I have created https://github.com/zfsonlinux/zfs-auto-snapshot/pull/77 which leaves the default as UTC but adds a program option --local-tz to allow using the local system's timezone.

polletfa commented 5 years ago

I made something similar but also added the timezone abbreviation to address the problem with DST: #105

adams13x13 commented 10 months ago

In fact, the UTC time seems to be the way to go. I have checked with the following configuration in the /etc/samba/smb.conf (not in the registry!)

vfs objects = shadowcopy2 shadow: snapdir = .zfs/snapshot shadow: sort = desc shadow: format = -%Y-%m-%d-%H%M shadow: snapprefix = ^zfs-auto-snap(frequent){0,1}(hourly){0,1}(daily){0,1}(monthly){0,1} shadow: delimiter = -20

I see the name zfs-auto-snap_frequent-2023-11-06-2145 of the snapshot on the ZFS volume in Linux, but windows 10 client converts it into the local time under "Previous versions".

I use "Samba version 4.17.12-Debian".