How to preserve files original creation date?

Kakenx picture Kakenx · Nov 28, 2013 · Viewed 51.6k times · Source

I'm moving files on the server from one directory to another using the file manager. Is there a way to preserve file creation date/time (when it was first added to server)? Someone suggested SSH, but I'm not very familiar with it. Does anyone have some good instructions on this?

Answer

Tharanga Abeyseela picture Tharanga Abeyseela · Nov 28, 2013

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).