I'm creating a tarball in a directory which has multiple sub-directories that I need to archive on a monthly basis. The issue is when I go to extract the files/folders for a particular month the top level sub-folders do not retain the modified date.
I am using the following for the tarball
find -type f -newermt 2021-12-01 ! -newermt 2021-12-31 | xargs tar -cvzf 2021-12.tar.gz
It still shows the time of the extract for each folder which I archived instead of when it was modified. Can someone help me out?
I also tried this as recommended on another user post
find -type f -newermt 2021-12-01 ! -newermt 2021-12-31 | xargs tar --atime-preserve -cvzf 2021-12.tar.gz
Thanks