Question

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?

Was it helpful?

Solution

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

OTHER TIPS

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

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top