Nice rsync on remote machine

Solution 1:

You can use the --rsync-path option, eg.

rsync --rsync-path="nice rsync" foo remotebox:/tmp/

Solution 2:

  • Taking the --rsync-path option you have rsync --rsync-path="ionice -c 3 nice -n 12 rsync" localDirectory remoteHost:/tmp/
  • Taking the configuration file option you can change or uncomment in file /etc/default/rsync the RSYNC_NICE='17' value and the RSYNC_IONICE='-c3' value

For both the ionice value will be for hard disc priority

  • 1 -> Real time
  • 2 -> Best effort
  • 3 -> Ildle (when any other process is not using the HD)

Note that for Linux only cfq scheduler really implements IO classes and priorities. If the remote system administrator has opted to IO scheduler noop, deadline or some more exotic variant you may find that ionice really does nothing. One should be able to get high performance from cfq and still be able to use IO classes and priorities by tuning cfq correctly.

for nice value for processor priority

  • -20 (most favorable to the process)
  • (default 10) if -n is not specified
  • 19 (least favorable to the process)

Solution 3:

You could disable the compression along the network, by not including the -z argument, that might save some CPU time on either side. Or change how rsync uses checksums, look at --checksum


Solution 4:

Quick and dirty solution would be to create a small wrapper script called 'rsync' that shadows the $PATH before real rsync binary like:

#!/bin/sh
nice -10 /path/to/proper/rsync $*

Or setup the authorized_keys file so that it performs nicing of rsync. (Assuming you are using ssh keys).

example:

command=”/home/user/bin/nice-rsync.sh" ssh-dss asdf....

Now in your /home/user/bin/nice-rsync.sh

#!/bin/sh
case $SSH_ORIGINAL_COMMAND in
  rsync\ --server*)
    nice -10 $SSH_ORIGINAL_COMMAND
    ;;
  *)
    $SSH_ORIGINAL_COMMAND
    ;;
esac

HTH

Tags:

Ssh

Rsync