Skip to content

Instantly share code, notes, and snippets.

@csghone
Created July 10, 2018 11:13
Show Gist options
  • Select an option

  • Save csghone/c2f934673cc798429c423c7cce801e31 to your computer and use it in GitHub Desktop.

Select an option

Save csghone/c2f934673cc798429c423c7cce801e31 to your computer and use it in GitHub Desktop.
rsync_test.sh
#!/bin/bash
HOST="192.168.1.4"
TEMP_IN="i1"
TEMP_OUT="o1"
delete_temp_files() {
rm $TEMP_IN
ssh $HOST rm $TEMP_OUT
}
CHUNK=100000000
INP_FILE=/dev/zero
# No append, No compression ' -av'
# Will use more CPU to checksum data
delete_temp_files
cat $INP_FILE |head -c $CHUNK > $TEMP_IN
rsync -av $TEMP_IN $HOST:~/$TEMP_OUT
# sent 100,024,511 bytes received 35 bytes 200,049,092.00 bytes/sec
# total size is 100,000,000 speedup is 1.00
cat $INP_FILE |head -c $CHUNK >> $TEMP_IN
rsync -av $TEMP_IN $HOST:~/$TEMP_OUT
# sent 80,107 bytes received 70,039 bytes 42,898.86 bytes/sec
# total size is 200,000,000 speedup is 1,332.04
# Only newer data is sent out and with compression
######################################################################
# No append, compression enabled ' -avz'
# Will use more CPU to checksum and compress data
delete_temp_files
cat $INP_FILE |head -c $CHUNK > $TEMP_IN
rsync -avz $TEMP_IN $HOST:~/$TEMP_OUT
# sent 97,354 bytes received 35 bytes 64,926.00 bytes/sec
# total size is 100,000,000 speedup is 1,026.81
cat $INP_FILE |head -c $CHUNK >> $TEMP_IN
rsync -avz $TEMP_IN $HOST:~/$TEMP_OUT
# sent 10,103 bytes received 70,039 bytes 22,897.71 bytes/sec
# total size is 200,000,000 speedup is 2,495.57
# Only newer data is sent out and in compressed size.
# However more traffic in 'received' data
######################################################################
# Append mode, with compression ' --append -vz'
# Lower CPU as checksum done only on incremental data
delete_temp_files
cat $INP_FILE |head -c $CHUNK > $TEMP_IN
rsync --append -vz $TEMP_IN $HOST:~/$TEMP_OUT
# sent 97,329 bytes received 35 bytes 64,909.33 bytes/sec
# total size is 100,000,000 speedup is 1,027.07
cat $INP_FILE |head -c $CHUNK >> $TEMP_IN
rsync --append -vz $TEMP_IN $HOST:~/$TEMP_OUT
# sent 97,329 bytes received 35 bytes 64,909.33 bytes/sec
# total size is 200,000,000 speedup is 2,054.15
# Only the new data is sent out and in compressed size
# Overall traffic 97329+35 similar to 10103+70039 in '-avz' mode
# Better time as given by 'bytes/sec'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment