2015-09-25 12:31:54 -04:00
|
|
|
#!/bin/sh
|
|
|
|
# this script should run as the 'git' user, not root, because of mkdir
|
|
|
|
#
|
|
|
|
# Example invocation:
|
|
|
|
# find /var/opt/gitlab/git-data/repositories -maxdepth 2 | \
|
|
|
|
# parallel-rsync-repos /var/opt/gitlab/git-data/repositories /mnt/gitlab/repositories
|
2015-10-05 12:02:12 -04:00
|
|
|
#
|
|
|
|
# You can also rsync to a remote destination.
|
|
|
|
#
|
|
|
|
# parallel-rsync-repos /var/opt/gitlab/git-data/repositories user@host:/mnt/gitlab/repositories
|
|
|
|
#
|
|
|
|
# If you need to pass extra options to rsync, set the RSYNC variable
|
|
|
|
#
|
|
|
|
# env RSYNC='rsync --rsh="foo bar"' parallel-rsync-repos /src dest
|
|
|
|
#
|
2015-09-25 12:31:54 -04:00
|
|
|
|
|
|
|
SRC=$1
|
|
|
|
DEST=$2
|
|
|
|
|
|
|
|
if [ -z "$JOBS" ] ; then
|
|
|
|
JOBS=10
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ -z "$SRC" ] || [ -z "$DEST" ] ; then
|
|
|
|
echo "Usage: $0 SRC DEST"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2015-10-05 12:02:12 -04:00
|
|
|
if [ -z "$RSYNC" ] ; then
|
|
|
|
RSYNC=rsync
|
|
|
|
fi
|
|
|
|
|
2015-09-25 12:31:54 -04:00
|
|
|
if ! cd $SRC ; then
|
|
|
|
echo "cd $SRC failed"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
sed "s|$SRC|./|" |\
|
2015-10-05 12:02:12 -04:00
|
|
|
parallel -j$JOBS --progress "mkdir -p $DEST/{} && $RSYNC --delete -a {}/. $DEST/{}/"
|