infra/codestorage/hg-repo-sync

Paddy 2015-11-12 Parent:cc08c8ed2128

4:32a993adf753 Go to Latest

infra/codestorage/hg-repo-sync/push.sh

Fix nested repository permissions. For repositories nested inside folders, fix the permissions on the folders so we can create other repositories inside them. Before, we only fixed the permissions on the repositories themselves; now we also fix the root directory that holds the repository.

History
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."