summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorDouwe Maan <douwe@gitlab.com>2015-12-08 22:34:03 +0100
committerDouwe Maan <douwe@gitlab.com>2015-12-08 22:34:03 +0100
commit8fb49a4b7005d7e57bb84d6fe5db97ff39d1064b (patch)
tree38118628101e0b9281a07c295d15d0c9f075197b /bin
parentf39ff54290abe224b0b79accc0da48c1cd2d2109 (diff)
parente616739e2fae12e5358d2cea40089a51468d9b4a (diff)
downloadgitlab-ce-8fb49a4b7005d7e57bb84d6fe5db97ff39d1064b.tar.gz
Merge branch 'master' into merge-if-green
# Conflicts: # app/views/projects/merge_requests/widget/_heading.html.haml # app/views/projects/merge_requests/widget/open/_accept.html.haml
Diffstat (limited to 'bin')
-rwxr-xr-xbin/parallel-rsync-repos54
1 files changed, 54 insertions, 0 deletions
diff --git a/bin/parallel-rsync-repos b/bin/parallel-rsync-repos
new file mode 100755
index 00000000000..21921148fa0
--- /dev/null
+++ b/bin/parallel-rsync-repos
@@ -0,0 +1,54 @@
+#!/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 transfer-success.log /var/opt/gitlab/git-data/repositories /mnt/gitlab/repositories
+#
+# You can also rsync to a remote destination.
+#
+# 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 transfer-success.log /src dest
+#
+
+LOGFILE=$1
+SRC=$2
+DEST=$3
+
+if [ -z "$LOGFILE" ] || [ -z "$SRC" ] || [ -z "$DEST" ] ; then
+ echo "Usage: $0 LOGFILE SRC DEST"
+ exit 1
+fi
+
+if [ -z "$JOBS" ] ; then
+ JOBS=10
+fi
+
+if [ -z "$RSYNC" ] ; then
+ RSYNC=rsync
+fi
+
+if ! cd $SRC ; then
+ echo "cd $SRC failed"
+ exit 1
+fi
+
+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