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
paddy@1 1 #!/bin/bash
paddy@1 2 today=$(date +%F)
paddy@1 3
paddy@1 4 DOMAIN=${DOMAIN:-code.secondbit.org}
paddy@1 5 BACKUP_BUCKET=${BACKUP_BUCKET:-backups.$DOMAIN}
paddy@1 6
paddy@1 7 echo "Fixing permissions..."
paddy@1 8 chgrp -R 2000 /mounted/repos
paddy@1 9
paddy@1 10 echo "Cleaning up..."
paddy@1 11 rm -rf /tmp/repos/*
paddy@1 12
paddy@1 13 repos=$(find /mounted/repos -name .hg -type d)
paddy@1 14 for repo in $repos
paddy@1 15 do
paddy@1 16 dir=$(dirname $repo)
paddy@1 17 stripped=${dir#.}
paddy@1 18 stripped=${stripped#/mounted/repos}
paddy@1 19 target=/tmp/repos/$today$stripped.bundle
paddy@1 20 mkdir -p $(dirname $target)
paddy@1 21 hg --cwd $dir bundle --all $target
paddy@1 22 done
paddy@1 23
paddy@1 24 echo "Pushing bundles to gs://${BACKUP_BUCKET}"
paddy@1 25 gsutil cp -R /tmp/repos/* gs://${BACKUP_BUCKET}/
paddy@1 26
paddy@1 27 echo "Cleaning up..."
paddy@1 28 rm -rf /tmp/repos/*
paddy@1 29
paddy@1 30 echo "Push complete."