Skip to content

Latest commit

 

History

History
56 lines (48 loc) · 1.72 KB

Rsync - The better way of copying data.md

File metadata and controls

56 lines (48 loc) · 1.72 KB
summary
Just some commands and explanations, because I always forget them...

The options

-v increase verbosity
-a archive mode; equals -rlptgoD (no -H,-A,-X)
    recurse into directories
    preserve symlinks
    preserve permissions
    preserve modification times
    preserve group
    preserve owner (super-user only)
    same as --devices --specials
        preserve device files (super-user only)
        preserve special files
-r recurse into directories
-h output numbers in a human-readable format
-P same as --partial --progress
    keep partially transferred files
    show progress during transfer
-z compress file data during the transfer
-x don't cross filesystem boundaries
-t preserve modification times
--dry-run perform a trial run with no changes made

Use cases

Here some copy-to-paste examples... You should only use -z on really fast systems and on remote transfer due its high need for at much CPU power!

Just a better cp

rsync -hvP [SOURCE] [DESTINATION]

Preserve every metadata

sudo rsync -ahvP [SOURCE] [DESTINATION]

How to remote

Just prepend a [USER]@[HOST]: before the source / target.

The slash on directories

I. Forget. It. EVERY. TIME. So here once and for all:

  • No slash The source dir itself will be copied within the destination dir.
  • Destination slash Same as no slash at all.
  • Source slash Every file within the source dir will be copied within the destination dir.
  • Both slash Same as source slash.

Note

  • Other ssh key needed? Add -e 'ssh -i /home/otheruser/.ssh/id_rsa'
  • To remove the source files simply add --remove-source-files and then clear up the empty folders with rm -rv [SOURCE]!