~linaro-automation/linaro-android-build-tools/trunk

« back to all changes in this revision

Viewing changes to backup/backup.sh

  • Committer: Paul Sokolovsky
  • Date: 2013-11-19 17:27:42 UTC
  • Revision ID: paul.sokolovsky@linaro.org-20131119172742-fhcaibckc6dklp8j
Add remote backup helper script.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/sh
 
2
#
 
3
# Script to automate Jenkins config configuration backup to git.
 
4
# This mostly deals with job config backups - commit other changes
 
5
# manually (with good commit messages).
 
6
#
 
7
set -x
 
8
 
 
9
HOST="ubuntu@android-build.linaro.org"
 
10
# Auth proxy (-A) is mandatory for push access
 
11
SSH_OPTS="-A"
 
12
SSH="ssh $SSH_OPTS"
 
13
 
 
14
 
 
15
if [ "$1" = "" ]; then
 
16
    echo "Usage: $0 status|diff|commit"
 
17
    exit 1
 
18
fi
 
19
 
 
20
if [ "$1" = "status" ]; then
 
21
    $SSH $HOST "cd /var/lib/jenkins; git status jobs"
 
22
elif [ "$1" = "status-all" ]; then
 
23
    $SSH $HOST "cd /var/lib/jenkins; git status"
 
24
elif [ "$1" = "diff" ]; then
 
25
    $SSH $HOST "cd /var/lib/jenkins; git diff jobs" | less
 
26
elif [ "$1" = "diff-all" ]; then
 
27
    $SSH $HOST "cd /var/lib/jenkins; git diff" | less
 
28
elif [ "$1" = "commit" ]; then
 
29
    if [ "$2" = "" ]; then
 
30
        msg="Routine jobs update"
 
31
        $SSH $HOST "cd /var/lib/jenkins; git commit -m \"$msg\" jobs"
 
32
        msg="Capture new jobs"
 
33
        $SSH $HOST "cd /var/lib/jenkins; git add jobs; git commit -m \"$msg\" jobs"
 
34
    else
 
35
        $SSH $HOST "cd /var/lib/jenkins; git commit -m \"$2\" jobs"
 
36
    fi
 
37
elif [ "$1" = "push" ]; then
 
38
    $SSH $HOST "cd /var/lib/jenkins; git push"
 
39
fi