How to preserve files original creation date?

SshFile Management

Ssh Problem Overview


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?

Ssh Solutions


Solution 1 - Ssh

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

Solution 2 - Ssh

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

Solution 3 - Ssh

You can do this on FileZilla once you have set up the ssh server on the remote machine: there is a preserve timestamp option on the Transfer menu.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionKakenxView Question on Stackoverflow
Solution 1 - SshTharanga AbeyseelaView Answer on Stackoverflow
Solution 2 - SshBoris VerkhovskiyView Answer on Stackoverflow
Solution 3 - SshSteve JView Answer on Stackoverflow