3

Is there a way to specify default rsync options per remote host? E.g. I have a NAS at 192.168.100.12; its rsync path is /opt/bin/rsync and its SSH port is 2222. It sucks to have to manually specify --rsync-path=/opt/bin/rsync -e 'ssh -p 2222' at every invocation of the rsync command.

2 Answers 2

1

rsync does not have a config file.

You can use an alias in your .bashrc:

alias nassync="rsync --rsync-path=/opt/bin/rsync -e 'ssh -p 2222'"
1

SSH Config

You can set any ssh options in ~/.ssh/config:

Host nas
    Hostname my-home-nas.duckdns.org
    Port 2222
    User app

Then whenever you reference nas by a command that uses SSH, those options will be applied:

rsync -avhP --bwlimit=5000 --size-only ./data/ nas:/backup/data/

PATH

On the remote system you can probably set export PATH=/opt/bin/:${PATH} near the top of ~/.profile so that /opt/bin is preferred over /usr/local/bin.

As a Command

If you want the command to be accessible by other users, or by commands that don't have a login profile, you could create a bash script for the rest:

/usr/local/bin/nas-rsync

#!/bin/bash
set -e
set -u

# --size-only so that metadata differences between FAT and EXT3
# or APFS don't cause retransfer

# add --bwlimit=5000 to limit bandwidth to 5MB/s - usefulif you have
# a really dumb switch that won't let other devices communicate when
# one device is maxing out a 100mbps connection

rsync -avhP --size-only -bwlimit=5000 /home/app/data/ nas:/backup/data/

You must log in to answer this question.

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