1

For a long time I've been wishing to replace scp in favor of rsync due to all the advantages and extra features of the latter (better performance, resuming interrupted downloads, displaying progress etc).

However I'm still stuck with scp: I'm too lazy to choose which options to use with rsync. Every time I need a specific feature (e.g. resuming an interrupted download) it takes minutes to research how to do it. Add to it the fact that rsync with no options has disadvantages over scp (e.g. it's less secure, if you don't use --rsh=ssh) and scp is just the laziest choice.

I'd like to pick a set of options once and for all, set up a good rscp alias and live happily ever after.

Can someone recommend a good set of options to use rsync to copy files over ssh?

1
  • 1. If I understand correctly,--rsh=ssh is the default for rsync. 2. If you want all permissions and ownership to be preserved, you can use sudo -avn source/ target. If you want to preserve hard links too, use sudo -Havn source/ target; There may be problems with some ownership and permissions without sudo (or without running as root), but you may not be able to do that at the remote side of the connection (at the ssh server).
    – sudodus
    Commented Dec 25, 2019 at 16:08

1 Answer 1

2

Aliasing

We can alias the best rsync configurations adding the following in your shell configuration file (be sure to add comunque to your $PATH if you are going to use it as shown):

~/.zshrc     (or ~/.bashrc)
-----------------------

rsync          = alias comunque "rsync -Phav {} {}"

rsync_no_links = alias comunque "rsync -rptgoDLK {} {}"

rsync_remote   = alias comunque "rsync -Phavz {} {}"

Make the shell see the new configuration:

source ~/.zshrc             # or .bashrc or whatever

Run

Now you can run your shiny new aliases as normal programs:

rsync source destination
rsync_no_links source destination
rsync_remote really_remote_source destination

Sources

4
  • 1
    Compression is really only useful over really slow connections (must be slower or much slower than the compression bandwidth), and there's a caveat with using a source that does/doesn't end with a /.
    – Kusalananda
    Commented Dec 25, 2019 at 16:03
  • This works, but doesn't enable many of the nice features of rsync... I was thinking about including --progress, --human-readable, something to resume interrupted downloads etc, in order to not having to look up how to achieve these things when I need them.
    – peoro
    Commented Dec 26, 2019 at 20:55
  • Why not just use ordinary shell functions?
    – Kusalananda
    Commented Dec 27, 2019 at 21:40
  • Because I do not like their syntax, so I try to avoid them whenever I can. Since these days Python is included in almost all setups, I've come to start advicing alias + comunque (tool to run shell commands with Python-like replacement syntax) instead of shell functions (in feasible situations) because of their extremely light syntax. Commented Dec 27, 2019 at 22:03

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .