3

to check "Daylight Saving Time" config for a time zone we can use this command: zdump -v <timezone>
However sometimes the policy of a country changes. new updates can be downloaded and be applied by this command: zic <timezone>
For Example (This is just an example, Australia had no changes):

  [root@test DST]# zdump -v Australia/Canberra | grep '2023'
  Australia/Canberra  Sat Apr  1 15:59:59 2023 UTC = Sun Apr  2 02:59:59 2023 AEDT isdst=1 gmtoff=39600
  Australia/Canberra  Sat Apr  1 16:00:00 2023 UTC = Sun Apr  2 02:00:00 2023 AEST isdst=0 gmtoff=36000 
  Australia/Canberra  Sat Sep 30 15:59:59 2023 UTC = Sun Oct  1 01:59:59 2023 AEST isdst=0 gmtoff=36000
  Australia/Canberra  Sat Sep 30 16:00:00 2023 UTC = Sun Oct  1 03:00:00 2023 AEDT isdst=1 gmtoff=39600
  [root@test DST]# zic australasia
  [root@test DST]# zdump -v Australia/Canberra | grep '2023'
  Australia/Canberra  Sat Apr  2 16:59:59 2023 UTC = Sun Apr  2 02:59:59 2023 AEDT isdst=1 gmtoff=39600
  Australia/Canberra  Sat Apr  2 17:00:00 2023 UTC = Sun Apr  2 02:00:00 2023 AEST isdst=0 gmtoff=36000
  Australia/Canberra  Sat Sep 29 16:59:59 2023 UTC = Sun Oct  1 01:59:59 2023 AEST isdst=0 gmtoff=36000
  Australia/Canberra  Sat Sep 29 17:00:00 2023 UTC = Sun Oct  1 03:00:00 2023 AEDT isdst=1 gmtoff=39600

what if there was a mistake and I wanted to restore changes? is there any way to backup previous config then apply new changes? if it is possible to take backup then how can I restore it?

BlackCrystal
  • 716
  • 14
  • 39

1 Answers1

1

From man tzfile:

... the timezone information files used by tzset(3) ... are typically found under one of the directories /usr/lib/zoneinfo or /usr/share/zoneinfo.

And man zic says:

/usr/local/etc/zoneinfo

   Standard directory used for created files.

Backing up those two directories would be a good start:

for d in /usr/lib/zoneinfo /usr/share/zoneinfo /usr/local/etc/zoneinfo
do
  [ -d "$d" ] && rsync -HAXa --delete "$d/" "$d.backup/"
done

If you need to restore later:

for d in /usr/lib/zoneinfo /usr/share/zoneinfo /usr/local/etc/zoneinfo
do
  [ -d "$d.backup" ] && rsync -HAXa --delete "$d.backup/" "$d/"
done
Jim L.
  • 7,188
  • 1
  • 13
  • 25
  • hi. I tested your answer and it worked. I was so sick that I was not able to do anything. I checked right now and I realized that bounty has expired while I was bedridden. I wanted to apologize for not getting your bounty. and thank u. – BlackCrystal Oct 18 '22 at 03:11