Skip to content

Instantly share code, notes, and snippets.

@alanorth
Last active January 29, 2018 16:58
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save alanorth/e91daa44ebe4e60bf3dd to your computer and use it in GitHub Desktop.
Save alanorth/e91daa44ebe4e60bf3dd to your computer and use it in GitHub Desktop.
Parallel rsync script for copying failed GlusterFS bricks (self-heal daemon is too slow!)
#!/bin/env bash
# borrowed / adapted from: https://wiki.ncsa.illinois.edu/display/~wglick/Parallel+Rsync
# RSYNC SETUP
RSYNC_PROG=/usr/bin/rsync
# note the important use of --relative to use relative paths so we don't have to specify the exact path on dest
RSYNC_OPTS="-aAXv --numeric-ids --progress --human-readable --delete --exclude=.glusterfs --relative"
export RSYNC_RSH="ssh -T -c arcfour -o Compression=no -x"
# ENV SETUP
SRCDIR=/path/to/good/brick
DESTDIR=/path/to/bad/brick
# Try to match number of CPUs on machine!
THREADS=4
BAD_NODE=server1
cd $SRCDIR
# COPY
# note the combination of -print0 and -0!
find {a..z}* {A..Z}* {0..1}* -mindepth 1 -maxdepth 1 -print0 | \
xargs -0 -n1 -P$THREADS -I% \
$RSYNC_PROG $RSYNC_OPTS "%" $BAD_NODE:$DESTDIR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment