diff options
author | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2015-12-08 15:08:22 +0100 |
---|---|---|
committer | Jacob Vosmaer <contact@jacobvosmaer.nl> | 2015-12-08 15:08:22 +0100 |
commit | f3ca92a062424e0cda2c077d9c30a4edbd6bf4c8 (patch) | |
tree | 9d01dcfe14e9873a876de9005e1608bfece53b45 /bin | |
parent | 6d2be0212c444c6a3d25ae6a3c75822fa1c8614f (diff) | |
download | gitlab-ce-f3ca92a062424e0cda2c077d9c30a4edbd6bf4c8.tar.gz |
Add 'resume' capability to parallel-rsync-repossync-all-repos
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/parallel-rsync-repos | 43 |
1 files changed, 29 insertions, 14 deletions
diff --git a/bin/parallel-rsync-repos b/bin/parallel-rsync-repos index b777056c95f..21921148fa0 100755 --- a/bin/parallel-rsync-repos +++ b/bin/parallel-rsync-repos @@ -1,29 +1,31 @@ -#!/bin/sh -# this script should run as the 'git' user, not root, because of mkdir +#!/usr/bin/env bash +# this script should run as the 'git' user, not root, because 'root' should not +# own intermediate directories created by rsync. # # Example invocation: # find /var/opt/gitlab/git-data/repositories -maxdepth 2 | \ -# parallel-rsync-repos /var/opt/gitlab/git-data/repositories /mnt/gitlab/repositories +# parallel-rsync-repos transfer-success.log /var/opt/gitlab/git-data/repositories /mnt/gitlab/repositories # # You can also rsync to a remote destination. # -# parallel-rsync-repos /var/opt/gitlab/git-data/repositories user@host:/mnt/gitlab/repositories +# parallel-rsync-repos transfer-success.log /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 +# env RSYNC='rsync --rsh="foo bar"' parallel-rsync-repos transfer-success.log /src dest # -SRC=$1 -DEST=$2 +LOGFILE=$1 +SRC=$2 +DEST=$3 -if [ -z "$JOBS" ] ; then - JOBS=10 +if [ -z "$LOGFILE" ] || [ -z "$SRC" ] || [ -z "$DEST" ] ; then + echo "Usage: $0 LOGFILE SRC DEST" + exit 1 fi -if [ -z "$SRC" ] || [ -z "$DEST" ] ; then - echo "Usage: $0 SRC DEST" - exit 1 +if [ -z "$JOBS" ] ; then + JOBS=10 fi if [ -z "$RSYNC" ] ; then @@ -35,5 +37,18 @@ if ! cd $SRC ; then exit 1 fi -sed "s|$SRC|./|" |\ - parallel -j$JOBS --progress "mkdir -p $DEST/{} && $RSYNC --delete -a {}/. $DEST/{}/" +rsyncjob() { + relative_dir="./${1#$SRC}" + + if ! $RSYNC --delete --relative -a "$relative_dir" "$DEST" ; then + echo "rsync $1 failed" + return 1 + fi + + echo "$1" >> $LOGFILE +} + +export LOGFILE SRC DEST RSYNC +export -f rsyncjob + +parallel -j$JOBS --progress rsyncjob |