bin sh Whitespace delimited repos to backup REPOS foo bar baz karabas

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
#!/bin/sh
# Whitespace delimited repos to backup
REPOS="/foo/bar /baz/karabas"
# Backup directory
BACKUP_DIR="/web/hg-repos"
for REPO in $REPOS; do
echo "Processing $REPO"
cd $BACKUP_DIR
NAME=$(basename $REPO)
if [ -e "$NAME" ]; then
echo "Pulling to $BACKUP_DIR/$NAME"
cd $NAME
hg pull $REPO
else
echo "Clone wasn't found. Cloning from $REPO to $BACKUP_DIR/$NAME!"
hg clone $REPO $NAME
fi
done