We need to backup the a/c/mtime-stamps of files and directories, and have the ability to restore them if necessary.
An example command to back up could be:
$ timestamp backup --all-stamps --incl-dir-stamps --recursive out.stampbak file.bin /dir/with/files/
And to restore could be:
$ timestamp restore --all-stamps out.stampbak
Does such a command exist to achieve the results I'm looking for? Nanosecond accuracy would be preferred, or anything else more granular, although I believe most filesystems stop at nanoseconds. POSIX compliance is also important as we need timestamps on both BSD and GNU/Linux systems to be backed/restored.
Edit: To clarify a few things, the filesystems I listed are, for the most part, holding on to files for now until I can ultimately move them to a master ZFS server. This is what made us consider the possibility of preserving time stamps before migrating data to ZFS. Just in case stamps were to change during the transfer process (we use several methods like HTTP, FTP, SMB), we want to ensure they can be restored to what they should be. Even post transfer, it would be beneficial to retain the timestamps as a small backup, so regardless of the fact the files will end up on ZFS, the question is still about backing/restoring timestamps only. Permissions and group information can be omitted from the backup.
The operating systems used for backing up timestamps include macOS Mojave 10.14.6, Ubuntu Server 18.04.5 LTS, Debian 10.2/7.8, FreeBSD 12.2 and CentOS 8. Restoring will mainly be done on the FreeBSD (ZFS server host), I don't think it will be necessary anywhere else. If it helps to mention, I have a few drives with files on NTFS partitions. Is it necessary to run a small Windows instance to back these stamps up properly?
Furthermore I was under the impression most filesystems used atime, ctime and mtime, and no others (I assume this ultimately differs between filesystems). My goal is to save and restore all of them, if possible.
I mentioned POSIX compliance in that, the tool can be used on either platform--I apologize if my description earlier was incorrect or inadequate. I also thought ctime = creation/birth time, I now see it's change time.
The timestamps of most importance to be retained are creation/birth time and modification time. Access time would be nice as well, change time is of least importance but would still help to have. Again, I apologize for the error, I'm still learning.
Edit 2: From this article I learned this:
there’s no file creation timestamp kept in most filesystems – meaning you can’t run a command like “show me all files created on certain date”. This said, it’s usually possible to deduce the same from ctime and mtime (if they match – this probably means that’s when the file was created).
When a new file or directory is created, usually all three times – atime, ctime and mtime – are configured to capture the current time.
Since the destination filesystem will be ZFS where timestamps of files/directories will be restored, it is probably best to at least save atime, ctime, mtime in case the filesystem the timestamps were saved from does not store a birthtime.