Sync Remote Directories

From Littledamien Wiki
Revision as of 20:08, 14 November 2021 by Video8 (talk | contribs)
Jump to navigation Jump to search

Use rsync on the command line:

$ rsync -av -e "ssh -p [NON_DEFAULT_SSH_PORT]" [USER]@[REMOTE_ADDRESS]:/path/to/remote/dir/ /path/to/local/dir
  • a flag: Stands for "archive" and copies recursively, preserving permissions, symbolic links, etc.
  • n flag: "Dry run" option for testing purposes.
  • v flag: Verbose.
  • e flag: Method for using a non-standard ssh port if the remote host is configured with a non-standard ssh port.

The order of remote vs local paths matters. Local path must be on the left in order push files on local to remote. Similarly, remote must be on the left to push files onto local.

  • --exclude specifies one subdirectory to exclude from the operation. The directory name must be followed with at trailing slash.
  • --delete option will cause target files and directories to be deleted if they are not found within the source directory.

Home directory on remote can be specified with ~ after the semicolon, e.g. [USER]@[REMOTE_ADDR]:~/path/below/home/