aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKelley Spoon <kelley.spoon@linaro.org>2018-10-25 08:14:01 -0500
committerKelley Spoon <kelley.spoon@linaro.org>2018-10-25 08:14:01 -0500
commit62a272b06962b9ec6d2e6bd76873e1feebad440c (patch)
tree2491d30f2f3b1fbbb9f65f93ce130120a36fb6e8
parent2caf613ed6f315146ccbd1c43608f986bcef5bee (diff)
downloadlinaro-git-tools-62a272b06962b9ec6d2e6bd76873e1feebad440c.tar.gz
mirror_cleaner: Add in script to prune mirror repos
This adds a script that can be used to clean out the mirrors of upstream git repositories. Change-Id: Ie695994872c6b7a6a879e4fee762323a9a454cff
-rwxr-xr-xmirror_cleaner.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/mirror_cleaner.sh b/mirror_cleaner.sh
new file mode 100755
index 0000000..8c91ed2
--- /dev/null
+++ b/mirror_cleaner.sh
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+BASE=/srv/mirror/gerrit-mirror
+
+umask 022
+
+# silence pushd/popd
+pushd () {
+ command pushd "$@" > /dev/null
+}
+
+popd () {
+ command popd "$@" > /dev/null
+}
+
+for repo in $(find $BASE -type d -name "*.git");
+do
+ echo "----- $repo"
+ pushd $repo
+ if [ -f gc.log ];
+ then
+ echo "WARNING: found ${repo}/gc.log"
+ cat ${repo}/gc.log
+ rm -f ${repo}/gc.log
+ fi
+
+ git reflog expire --expire=now --all
+ ionice -c2 -n7 -- git gc --prune=now --aggressive >/dev/null
+done