#!/bin/bash -e

. common.sh;
. local/backupcredentials.sh;

mkdir -p $backuphome 2>/dev/null;

repos=$(curl -s http://${backupcredentials}@${domain}/private/tools/links.txt)

for repo in ${repos}; do
    if [ ! -d ${backuphome}/${repo} ]; then
        /usr/local/bin/hg clone http://${backupcredentials}@${domain}/repo/${repo} ${backuphome}/${repo};
    else
        /usr/local/bin/hg pull -R ${backuphome}/${repo} -u http://${backupcredentials}@${domain}/repo/${repo};
    fi;
done;
