If you want to mirror a remote directory via SSH, you may want to use the wonderful rsync command.
The rsync executable has many options, so, which is the correct option list to make an exact copy of a remote directory, maintaining permissions, ownerships, timestampts, copying only the modified files, and updating only the pieces of modified files?
Let me begin with an example. We want to full mirror the directory /mystuff on server 18.104.22.168 into /mystufflocal. The files deleted on 22.214.171.124 from the previous rsync will be removed locally too, so pay attention! If you don’t want to locally remove deleted files you can remove the “–delete” option.
If you want to compress the stream in transit you can add the “-z” option.
All we have to do is:
rsync -vartuh –inplace –delete –progress –stats -e “ssh -carcfour128”
The trailing slashes are important because are used by rsync to understand precisely what should be transferred and where.