infra/codestorage/hg-repo-sync
2015-10-11
Parent:cc08c8ed2128
infra/codestorage/hg-repo-sync/push.sh
Use pip to install Mercurial, pin to 3.5.2 We want to use a relatively recent (but consistent) version of Mercurial, so I had to switch to using pip to install Mercurial, so I could pin it to version 3.5.2. apt-get didn't have version 3 available.
1 #!/bin/bash
2 today=$(date +%F)
4 DOMAIN=${DOMAIN:-code.secondbit.org}
5 BACKUP_BUCKET=${BACKUP_BUCKET:-backups.$DOMAIN}
7 echo "Fixing permissions..."
8 chgrp -R 2000 /mounted/repos
10 echo "Cleaning up..."
11 rm -rf /tmp/repos/*
13 repos=$(find /mounted/repos -name .hg -type d)
14 for repo in $repos
15 do
16 dir=$(dirname $repo)
17 stripped=${dir#.}
18 stripped=${stripped#/mounted/repos}
19 target=/tmp/repos/$today$stripped.bundle
20 mkdir -p $(dirname $target)
21 hg --cwd $dir bundle --all $target
22 done
24 echo "Pushing bundles to gs://${BACKUP_BUCKET}"
25 gsutil cp -R /tmp/repos/* gs://${BACKUP_BUCKET}/
27 echo "Cleaning up..."
28 rm -rf /tmp/repos/*
30 echo "Push complete."