How to preserve files original creation date?
You can also rsync over SSH with the -t
or --times
option
rsync -P -e ssh -t <source> <destination>
I like to use the -P
option (same as --partial --progress
) because it doesn't delete all the files if you stop the transfer (or it fails) halfway through and it reports progress. See man rsync
-t, --times
This tells rsync to transfer modification times along with the
files and update them on the remote system. Note that if this op‐
tion is not used, the optimization that excludes files that have
not been modified cannot be effective; in other words, a missing
-t or -a will cause the next transfer to behave as if it used -I,
causing all files to be updated (though rsync’s delta-transfer al‐
gorithm will make the update fairly efficient if the files haven’t
actually changed, you’re much better off using -t).
Use scp
with the -p
option.
-p Preserves modification times, access times, and modes from the original file.
Example command copying a file from local to remote server:
scp -p /home/mylocaldata/test.txt remote.example.com:/home/remote_dir
Note that this will not preserve user and group only permission flags (rwx and such).