Last active
October 17, 2017 18:45
-
-
Save timmahoney/8c0e2ff1f415d8d4afe0 to your computer and use it in GitHub Desktop.
Parallel RSync
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 | |
if [[ -z "$1" ]] || [[ -z "$2" ]]; then | |
exit 1 | |
fi | |
# SETUP OPTIONS | |
export SRCDIR="$1" | |
export DESTDIR="$2" | |
export THREADS="4" | |
# RSYNC DIRECTORY STRUCTURE | |
rsync -zr -f"+ */" -f"- *" $SRCDIR/ $DESTDIR/ | |
# FOLLOWING MAYBE FASTER BUT NOT AS FLEXIBLE | |
# cd $SRCDIR; find . -type d -print0 | cpio -0pdm $DESTDIR/ | |
# FIND ALL FILES AND PASS THEM TO MULTIPLE RSYNC PROCESSES | |
cd $SRCDIR && find $SRCDIR ! -type d -printf "%f\n" | xargs -P$THREADS -I {} rsync -avz {} $DESTDIR/{} | |
# IF YOU WANT TO LIMIT THE IO PRIORITY, | |
# PREPEND THE FOLLOWING TO THE rsync & cd/find COMMANDS ABOVE: | |
# ionice -c2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment