Linux – How to copy directory from one Linux server to another with a minimum in-between period

linuxrsyncscp

I have a rather big directory on one server (over 4000 files), which I'd like to copy to another server (which contains a previous version of this directory). rsync is the first option, but it will put the destination folder into waiting status for a rather long period of time (more than a minute).

I'd like to do it a bit differently:

  1. gzip the source folder
  2. scp the archive to the destination server
  3. gunzip the file there
  4. delete the archive at the source and the destination

What is the best way to accomplish all this?

Best Answer

rsync has --delay-updates which seems to be what you need:

«…

This option puts the temporary file from each updated file into a holding directory until the end of the transfer, at which time all the files are renamed into place in rapid succession. This attempts to make the updating of the files a little more atomic. By default the files are placed into a directory named ".~tmp~" in each

…»