Last active
August 27, 2017 15:19
-
-
Save gwpl/2baf269b7a2c9d10d78d625844b95202 to your computer and use it in GitHub Desktop.
./bash_test_rsync_options.sh # testing different rsync options and how outputs look like # TODO: extend with xattr test case and my favourite options combo 'rsync -aAXHzvR --progress' (# tweeted: https://twitter.com/GWierzowiecki/status/901825874416295936 )
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
tmpdir="$(mktemp -d)" | |
function cleanup { | |
echo '@ cleanup {' | |
set -x | |
rm -r "$tmpdir" | |
set +x | |
echo '@ } end of cleanup' | |
} | |
trap cleanup EXIT INT TERM QUIT | |
# Prepare Origin | |
o="$tmpdir/origin" | |
function make_origin { | |
echo '@ make_origin { # Preparation of origin started:' | |
#set -x | |
mkdir -p "$o" | |
touch "$o/"file_{not_modified,to_be_removed,to_be_touched} | |
echo "Line1" > "$o/file_to_be_extended" | |
ln "$o/file_to_be_extended" "$o/hard_link_to_file_to_be_extended" | |
echo "Origianl Content" > "$o/file_to_be_altered" | |
# ls -lha "$o" | |
# set +x | |
echo '@ } # End of make_origin' | |
} | |
function apply_intended_changes { | |
echo '@ apply_intended_changes to origin {' | |
# set -x | |
rm "$o/"file_to_be_removed | |
sleep 0.1 | |
touch "$o/"file_to_be_touched | |
echo "Line 2" >> "$o/file_to_be_extended" | |
echo "New Content" > "$o/file_to_be_altered" | |
# ls -lha "$o" | |
# set +x | |
echo '@ } # End of apply_intended_changes' | |
} | |
function clean_origin { | |
rm -r "$o" | |
} | |
( | |
echo ' | |
####################################### | |
@ Test cp 1: cp -a and later rsync -a' | |
d="$tmpdir/test_cp1" | |
make_origin | |
set -x | |
cp -rp "$o" "$d" | |
rsync -a "$o/" "$d/" | |
set +x | |
clean_origin | |
echo ' | |
####################################### | |
@ Test cp 2: cp -a; rsync -a; apply_intended_changes; rsync -a' | |
d="$tmpdir/test_cp2" | |
make_origin | |
set -x | |
cp -rp "$o" "$d" | |
rsync -a "$o/" "$d/" | |
apply_intended_changes | |
rsync -a "$o/" "$d/" | |
set +x | |
clean_origin | |
echo ' | |
####################################### | |
@ Test rsync 1: 2x rsync -a --progress' | |
d="$tmpdir/test_rsync1" | |
make_origin | |
set -x | |
rsync -a --progress "$o/" "$d/" | |
rsync -a --progress "$o/" "$d/" | |
set +x | |
clean_origin | |
echo ' | |
####################################### | |
@ Test rsync 2: rsync -a --progress; apply_intended_changes; rsync -a --progress' | |
d="$tmpdir/test_rsync2" | |
make_origin | |
set -x | |
rsync -a --progress "$o/" "$d/" | |
apply_intended_changes | |
rsync -a --progress "$o/" "$d/" | |
set +x | |
clean_origin | |
echo ' | |
####################################### | |
@ Test rsync 3: rsync -a --progress --delete; apply_intended_changes; rsync -a --progress --delete' | |
d="$tmpdir/test_rsync3" | |
make_origin | |
set -x | |
rsync -a --progress --delete "$o/" "$d/" | |
apply_intended_changes | |
rsync -a --progress --delete "$o/" "$d/" | |
set +x | |
clean_origin | |
echo ' | |
####################################### | |
@ Test rsync 4: rsync -a -v --progress --delete; apply_intended_changes; rsync -a -v --progress --delete' | |
d="$tmpdir/test_rsync4" | |
make_origin | |
set -x | |
rsync -a -v --progress --delete "$o/" "$d/" | |
apply_intended_changes | |
rsync -a -v --progress --delete "$o/" "$d/" | |
set +x | |
clean_origin | |
echo ' | |
####################################### | |
@ Test rsync 5: rsync -a -v -v --progress --delete; apply_intended_changes; rsync -a -v -v --progress --delete' | |
d="$tmpdir/test_rsync4" | |
make_origin | |
set -x | |
rsync -a -v -v --progress --delete "$o/" "$d/" | |
apply_intended_changes | |
rsync -a -v -v --progress --delete "$o/" "$d/" | |
set +x | |
clean_origin | |
echo ' | |
####################################### | |
@ Test rsync 6: rsync -avvH --progress --delete; apply_intended_changes; rsync -avvH --progress --delete' | |
d="$tmpdir/test_rsync4" | |
make_origin | |
set -x | |
rsync -avvH --progress --delete "$o/" "$d/" | |
apply_intended_changes | |
rsync -avvH --progress --delete "$o/" "$d/" | |
set +x | |
clean_origin | |
echo ' | |
####################################### | |
@ END of all tests' | |
) 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
####################################### | |
@ Test cp 1: cp -a and later rsync -a | |
@ make_origin { # Preparation of origin started: | |
@ } # End of make_origin | |
+ cp -rp /tmp/tmp.QZoAR8o7EF/origin /tmp/tmp.QZoAR8o7EF/test_cp1 | |
+ rsync -a /tmp/tmp.QZoAR8o7EF/origin/ /tmp/tmp.QZoAR8o7EF/test_cp1/ | |
+ set +x | |
####################################### | |
@ Test cp 2: cp -a; rsync -a; apply_intended_changes; rsync -a | |
@ make_origin { # Preparation of origin started: | |
@ } # End of make_origin | |
+ cp -rp /tmp/tmp.QZoAR8o7EF/origin /tmp/tmp.QZoAR8o7EF/test_cp2 | |
+ rsync -a /tmp/tmp.QZoAR8o7EF/origin/ /tmp/tmp.QZoAR8o7EF/test_cp2/ | |
+ apply_intended_changes | |
+ echo '@ apply_intended_changes to origin {' | |
@ apply_intended_changes to origin { | |
+ rm /tmp/tmp.QZoAR8o7EF/origin/file_to_be_removed | |
+ sleep 0.1 | |
+ touch /tmp/tmp.QZoAR8o7EF/origin/file_to_be_touched | |
+ echo 'Line 2' | |
+ echo 'New Content' | |
+ echo '@ } # End of apply_intended_changes' | |
@ } # End of apply_intended_changes | |
+ rsync -a /tmp/tmp.QZoAR8o7EF/origin/ /tmp/tmp.QZoAR8o7EF/test_cp2/ | |
+ set +x | |
####################################### | |
@ Test rsync 1: 2x rsync -a --progress | |
@ make_origin { # Preparation of origin started: | |
@ } # End of make_origin | |
+ rsync -a --progress /tmp/tmp.QZoAR8o7EF/origin/ /tmp/tmp.QZoAR8o7EF/test_rsync1/ | |
sending incremental file list | |
created directory /tmp/tmp.QZoAR8o7EF/test_rsync1 | |
./ | |
file_not_modified | |
0 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=5/7) | |
file_to_be_altered | |
17 100% 0.00kB/s 0:00:00 | |
17 100% 0.00kB/s 0:00:00 (xfr#2, to-chk=4/7) | |
file_to_be_extended | |
6 100% 5.86kB/s 0:00:00 | |
6 100% 5.86kB/s 0:00:00 (xfr#3, to-chk=3/7) | |
file_to_be_removed | |
0 100% 0.00kB/s 0:00:00 (xfr#4, to-chk=2/7) | |
file_to_be_touched | |
0 100% 0.00kB/s 0:00:00 (xfr#5, to-chk=1/7) | |
hard_link_to_file_to_be_extended | |
6 100% 5.86kB/s 0:00:00 | |
6 100% 5.86kB/s 0:00:00 (xfr#6, to-chk=0/7) | |
+ rsync -a --progress /tmp/tmp.QZoAR8o7EF/origin/ /tmp/tmp.QZoAR8o7EF/test_rsync1/ | |
sending incremental file list | |
+ set +x | |
####################################### | |
@ Test rsync 2: rsync -a --progress; apply_intended_changes; rsync -a --progress | |
@ make_origin { # Preparation of origin started: | |
@ } # End of make_origin | |
+ rsync -a --progress /tmp/tmp.QZoAR8o7EF/origin/ /tmp/tmp.QZoAR8o7EF/test_rsync2/ | |
sending incremental file list | |
created directory /tmp/tmp.QZoAR8o7EF/test_rsync2 | |
./ | |
file_not_modified | |
0 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=5/7) | |
file_to_be_altered | |
17 100% 0.00kB/s 0:00:00 | |
17 100% 0.00kB/s 0:00:00 (xfr#2, to-chk=4/7) | |
file_to_be_extended | |
6 100% 5.86kB/s 0:00:00 | |
6 100% 5.86kB/s 0:00:00 (xfr#3, to-chk=3/7) | |
file_to_be_removed | |
0 100% 0.00kB/s 0:00:00 (xfr#4, to-chk=2/7) | |
file_to_be_touched | |
0 100% 0.00kB/s 0:00:00 (xfr#5, to-chk=1/7) | |
hard_link_to_file_to_be_extended | |
6 100% 5.86kB/s 0:00:00 | |
6 100% 5.86kB/s 0:00:00 (xfr#6, to-chk=0/7) | |
+ apply_intended_changes | |
+ echo '@ apply_intended_changes to origin {' | |
@ apply_intended_changes to origin { | |
+ rm /tmp/tmp.QZoAR8o7EF/origin/file_to_be_removed | |
+ sleep 0.1 | |
+ touch /tmp/tmp.QZoAR8o7EF/origin/file_to_be_touched | |
+ echo 'Line 2' | |
+ echo 'New Content' | |
+ echo '@ } # End of apply_intended_changes' | |
@ } # End of apply_intended_changes | |
+ rsync -a --progress /tmp/tmp.QZoAR8o7EF/origin/ /tmp/tmp.QZoAR8o7EF/test_rsync2/ | |
sending incremental file list | |
file_to_be_altered | |
12 100% 0.00kB/s 0:00:00 | |
12 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=3/6) | |
file_to_be_extended | |
13 100% 12.70kB/s 0:00:00 | |
13 100% 12.70kB/s 0:00:00 (xfr#2, to-chk=2/6) | |
hard_link_to_file_to_be_extended | |
13 100% 12.70kB/s 0:00:00 | |
13 100% 12.70kB/s 0:00:00 (xfr#3, to-chk=0/6) | |
+ set +x | |
####################################### | |
@ Test rsync 3: rsync -a --progress --delete; apply_intended_changes; rsync -a --progress --delete | |
@ make_origin { # Preparation of origin started: | |
@ } # End of make_origin | |
+ rsync -a --progress --delete /tmp/tmp.QZoAR8o7EF/origin/ /tmp/tmp.QZoAR8o7EF/test_rsync3/ | |
sending incremental file list | |
created directory /tmp/tmp.QZoAR8o7EF/test_rsync3 | |
./ | |
file_not_modified | |
0 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=5/7) | |
file_to_be_altered | |
17 100% 0.00kB/s 0:00:00 | |
17 100% 0.00kB/s 0:00:00 (xfr#2, to-chk=4/7) | |
file_to_be_extended | |
6 100% 5.86kB/s 0:00:00 | |
6 100% 5.86kB/s 0:00:00 (xfr#3, to-chk=3/7) | |
file_to_be_removed | |
0 100% 0.00kB/s 0:00:00 (xfr#4, to-chk=2/7) | |
file_to_be_touched | |
0 100% 0.00kB/s 0:00:00 (xfr#5, to-chk=1/7) | |
hard_link_to_file_to_be_extended | |
6 100% 5.86kB/s 0:00:00 | |
6 100% 5.86kB/s 0:00:00 (xfr#6, to-chk=0/7) | |
+ apply_intended_changes | |
+ echo '@ apply_intended_changes to origin {' | |
@ apply_intended_changes to origin { | |
+ rm /tmp/tmp.QZoAR8o7EF/origin/file_to_be_removed | |
+ sleep 0.1 | |
+ touch /tmp/tmp.QZoAR8o7EF/origin/file_to_be_touched | |
+ echo 'Line 2' | |
+ echo 'New Content' | |
+ echo '@ } # End of apply_intended_changes' | |
@ } # End of apply_intended_changes | |
+ rsync -a --progress --delete /tmp/tmp.QZoAR8o7EF/origin/ /tmp/tmp.QZoAR8o7EF/test_rsync3/ | |
sending incremental file list | |
deleting file_to_be_removed | |
file_to_be_altered | |
12 100% 0.00kB/s 0:00:00 | |
12 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=3/6) | |
file_to_be_extended | |
13 100% 12.70kB/s 0:00:00 | |
13 100% 12.70kB/s 0:00:00 (xfr#2, to-chk=2/6) | |
hard_link_to_file_to_be_extended | |
13 100% 12.70kB/s 0:00:00 | |
13 100% 12.70kB/s 0:00:00 (xfr#3, to-chk=0/6) | |
+ set +x | |
####################################### | |
@ Test rsync 4: rsync -a -v --progress --delete; apply_intended_changes; rsync -a -v --progress --delete | |
@ make_origin { # Preparation of origin started: | |
@ } # End of make_origin | |
+ rsync -a -v --progress --delete /tmp/tmp.QZoAR8o7EF/origin/ /tmp/tmp.QZoAR8o7EF/test_rsync4/ | |
sending incremental file list | |
created directory /tmp/tmp.QZoAR8o7EF/test_rsync4 | |
./ | |
file_not_modified | |
0 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=5/7) | |
file_to_be_altered | |
17 100% 0.00kB/s 0:00:00 | |
17 100% 0.00kB/s 0:00:00 (xfr#2, to-chk=4/7) | |
file_to_be_extended | |
6 100% 5.86kB/s 0:00:00 | |
6 100% 5.86kB/s 0:00:00 (xfr#3, to-chk=3/7) | |
file_to_be_removed | |
0 100% 0.00kB/s 0:00:00 (xfr#4, to-chk=2/7) | |
file_to_be_touched | |
0 100% 0.00kB/s 0:00:00 (xfr#5, to-chk=1/7) | |
hard_link_to_file_to_be_extended | |
6 100% 5.86kB/s 0:00:00 | |
6 100% 5.86kB/s 0:00:00 (xfr#6, to-chk=0/7) | |
sent 503 bytes received 187 bytes 1,380.00 bytes/sec | |
total size is 29 speedup is 0.04 | |
+ apply_intended_changes | |
+ echo '@ apply_intended_changes to origin {' | |
@ apply_intended_changes to origin { | |
+ rm /tmp/tmp.QZoAR8o7EF/origin/file_to_be_removed | |
+ sleep 0.1 | |
+ touch /tmp/tmp.QZoAR8o7EF/origin/file_to_be_touched | |
+ echo 'Line 2' | |
+ echo 'New Content' | |
+ echo '@ } # End of apply_intended_changes' | |
@ } # End of apply_intended_changes | |
+ rsync -a -v --progress --delete /tmp/tmp.QZoAR8o7EF/origin/ /tmp/tmp.QZoAR8o7EF/test_rsync4/ | |
sending incremental file list | |
deleting file_to_be_removed | |
file_to_be_altered | |
12 100% 0.00kB/s 0:00:00 | |
12 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=3/6) | |
file_to_be_extended | |
13 100% 12.70kB/s 0:00:00 | |
13 100% 12.70kB/s 0:00:00 (xfr#2, to-chk=2/6) | |
hard_link_to_file_to_be_extended | |
13 100% 12.70kB/s 0:00:00 | |
13 100% 12.70kB/s 0:00:00 (xfr#3, to-chk=0/6) | |
sent 373 bytes received 95 bytes 936.00 bytes/sec | |
total size is 38 speedup is 0.08 | |
+ set +x | |
####################################### | |
@ Test rsync 5: rsync -a -v -v --progress --delete; apply_intended_changes; rsync -a -v -v --progress --delete | |
@ make_origin { # Preparation of origin started: | |
@ } # End of make_origin | |
+ rsync -a -v -v --progress --delete /tmp/tmp.QZoAR8o7EF/origin/ /tmp/tmp.QZoAR8o7EF/test_rsync4/ | |
sending incremental file list | |
delta-transmission disabled for local transfer or --whole-file | |
file_not_modified | |
file_to_be_touched | |
file_to_be_altered | |
17 100% 0.00kB/s 0:00:00 | |
17 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=4/7) | |
file_to_be_extended | |
6 100% 5.86kB/s 0:00:00 | |
6 100% 5.86kB/s 0:00:00 (xfr#2, to-chk=3/7) | |
file_to_be_removed | |
0 100% 0.00kB/s 0:00:00 (xfr#3, to-chk=2/7) | |
hard_link_to_file_to_be_extended | |
6 100% 5.86kB/s 0:00:00 | |
6 100% 5.86kB/s 0:00:00 (xfr#4, to-chk=0/7) | |
total: matches=0 hash_hits=0 false_alarms=0 data=29 | |
sent 431 bytes received 213 bytes 1,288.00 bytes/sec | |
total size is 29 speedup is 0.05 | |
+ apply_intended_changes | |
+ echo '@ apply_intended_changes to origin {' | |
@ apply_intended_changes to origin { | |
+ rm /tmp/tmp.QZoAR8o7EF/origin/file_to_be_removed | |
+ sleep 0.1 | |
+ touch /tmp/tmp.QZoAR8o7EF/origin/file_to_be_touched | |
+ echo 'Line 2' | |
+ echo 'New Content' | |
+ echo '@ } # End of apply_intended_changes' | |
@ } # End of apply_intended_changes | |
+ rsync -a -v -v --progress --delete /tmp/tmp.QZoAR8o7EF/origin/ /tmp/tmp.QZoAR8o7EF/test_rsync4/ | |
sending incremental file list | |
delta-transmission disabled for local transfer or --whole-file | |
deleting file_to_be_removed | |
file_not_modified is uptodate | |
file_to_be_touched | |
file_to_be_altered | |
12 100% 0.00kB/s 0:00:00 | |
12 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=3/6) | |
file_to_be_extended | |
13 100% 12.70kB/s 0:00:00 | |
13 100% 12.70kB/s 0:00:00 (xfr#2, to-chk=2/6) | |
hard_link_to_file_to_be_extended | |
13 100% 12.70kB/s 0:00:00 | |
13 100% 12.70kB/s 0:00:00 (xfr#3, to-chk=0/6) | |
total: matches=0 hash_hits=0 false_alarms=0 data=38 | |
sent 382 bytes received 228 bytes 1,220.00 bytes/sec | |
total size is 38 speedup is 0.06 | |
+ set +x | |
####################################### | |
@ Test rsync 6: rsync -avvH --progress --delete; apply_intended_changes; rsync -avvH --progress --delete | |
@ make_origin { # Preparation of origin started: | |
@ } # End of make_origin | |
+ rsync -avvH --progress --delete /tmp/tmp.QZoAR8o7EF/origin/ /tmp/tmp.QZoAR8o7EF/test_rsync4/ | |
sending incremental file list | |
delta-transmission disabled for local transfer or --whole-file | |
file_not_modified | |
file_to_be_touched | |
file_to_be_altered | |
17 100% 0.00kB/s 0:00:00 | |
17 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=4/7) | |
file_to_be_extended | |
6 100% 5.86kB/s 0:00:00 | |
6 100% 5.86kB/s 0:00:00 (xfr#2, to-chk=3/7) | |
file_to_be_removed | |
0 100% 0.00kB/s 0:00:00 (xfr#3, to-chk=2/7) | |
hard_link_to_file_to_be_extended => file_to_be_extended | |
total: matches=0 hash_hits=0 false_alarms=0 data=23 | |
sent 402 bytes received 221 bytes 1,246.00 bytes/sec | |
total size is 29 speedup is 0.05 | |
+ apply_intended_changes | |
+ echo '@ apply_intended_changes to origin {' | |
@ apply_intended_changes to origin { | |
+ rm /tmp/tmp.QZoAR8o7EF/origin/file_to_be_removed | |
+ sleep 0.1 | |
+ touch /tmp/tmp.QZoAR8o7EF/origin/file_to_be_touched | |
+ echo 'Line 2' | |
+ echo 'New Content' | |
+ echo '@ } # End of apply_intended_changes' | |
@ } # End of apply_intended_changes | |
+ rsync -avvH --progress --delete /tmp/tmp.QZoAR8o7EF/origin/ /tmp/tmp.QZoAR8o7EF/test_rsync4/ | |
sending incremental file list | |
delta-transmission disabled for local transfer or --whole-file | |
deleting file_to_be_removed | |
file_not_modified is uptodate | |
file_to_be_altered | |
12 100% 0.00kB/s 0:00:00 | |
12 100% 0.00kB/s 0:00:00 (xfr#1, to-chk=3/6) | |
file_to_be_extended | |
13 100% 12.70kB/s 0:00:00 | |
13 100% 12.70kB/s 0:00:00 (xfr#2, to-chk=2/6) | |
file_to_be_touched | |
0 100% 0.00kB/s 0:00:00 (xfr#3, to-chk=1/6) | |
hard_link_to_file_to_be_extended => file_to_be_extended | |
total: matches=0 hash_hits=0 false_alarms=0 data=25 | |
sent 383 bytes received 229 bytes 1,224.00 bytes/sec | |
total size is 38 speedup is 0.06 | |
+ set +x | |
####################################### | |
@ END of all tests | |
@ cleanup { | |
@ } end of cleanup |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment