eolas/zk/rsync.md

1.3 KiB

tags created
file-transfer
Linux
procedural
disks
Saturday, April 26, 2025

rsync

Ordering

Local to local

SOURCE_DIR > TARGET_DIR

Local to remote

LOCAL_SOURC_DIR > REMOTE_TARGET_DIR

Remote to local

REMOTE_TARGET_DIR > LOCAL_SOURC_DIR
rsync -a <dir_to_copy_to> <dir_to_copy_from>

Expanding directories

The following:

rsync -a local_dir  target_dir

Will create /target_dir/local_dir at the target. In other words it will nest the actual directory you are interested in within what you have named the target.

To avoid this, add a slash to the source directory, viz:

rysync -a local_dir/ target_dir

Now, at the target, there will just be local_dir.

Standard options I use

rsync -vzP
  • verbose output

  • use compression (only really useful when running rysnc over a network)

  • display progress

  • preserve partially copied filed and resume if network connection interrupted

Archive mode

Use "archive mode" when specifically wanting to create a backup of a directory (i.e. for long term storage rather than immediate use).

rsync -a

Archive mode is an umbrella for the following flags:

  • -r: recursive

  • l: copy symlinks as symlinks

  • p: preserve permissions

  • t: preserve times

  • g: preserve group