backup_bitbucket: New role
This commit is contained in:
parent
7496125098
commit
0d72e9e920
3 changed files with 59 additions and 0 deletions
24
roles/backup_bitbucket/files/backup-bitbucket.sh
Normal file
24
roles/backup_bitbucket/files/backup-bitbucket.sh
Normal file
|
@ -0,0 +1,24 @@
|
|||
#!/bin/sh
|
||||
|
||||
USERS="tmakinen"
|
||||
|
||||
set -eu
|
||||
umask 027
|
||||
|
||||
cd /srv/backup/bitbucket.org
|
||||
|
||||
for _user in $USERS ; do
|
||||
curl -sSf "https://api.bitbucket.org/2.0/repositories/${_user}" | \
|
||||
jq -r '.values | .[] | [.name, .scm] | @tsv' | \
|
||||
while read -r _repo _scm
|
||||
do
|
||||
[ "$_scm" = "git" ] || continue
|
||||
_url="https://bitbucket.org/${_user}/${_repo}"
|
||||
_gitdir="${_user}/${_repo}"
|
||||
if [ ! -d "$_gitdir" ]; then
|
||||
mkdir -p "$_gitdir"
|
||||
git --git-dir="$_gitdir" init --quiet --bare
|
||||
fi
|
||||
git --git-dir="$_gitdir" fetch --quiet --force --prune --tags "$_url" "refs/heads/*:refs/heads/*"
|
||||
done
|
||||
done
|
Loading…
Add table
Add a link
Reference in a new issue