Project

General

Profile

Download (675 Bytes) Statistics
| Branch: | Tag: | Revision:

calebasse / reinit-psql.sh @ 9b58dc83

1 3fb150de Jérôme Schneider
#!/bin/bash
2
3 2a56d9e8 Jérôme Schneider
DUMP='last_dump.sql.bz2'
4
HELP="./`basename $0` [new|dl]"
5
6
if [ $# -gt 1 ]; then
7
    echo $HELP
8
    exit 1
9
fi
10
11 9a30dadc Jérôme Schneider
if [ $# -gt 0 ]; then
12 2a56d9e8 Jérôme Schneider
    if [ "$1" != "new" -a "$1" != "dl" ]; then
13
        echo $HELP
14
        exit 1
15
    fi
16
fi
17 3fb150de Jérôme Schneider
18
sudo -u postgres dropdb calebasse
19
sudo -u postgres createdb calebasse -O $USER
20
21 9a30dadc Jérôme Schneider
if [ $# -gt 0 ]; then
22 2a56d9e8 Jérôme Schneider
    if [ $1 = "new" ]; then
23
        ssh calebasse.aps42.entrouvert.com ssh prod "/etc/cron.daily/calebasse_dumpdb"
24
    fi
25
    ssh calebasse.aps42.entrouvert.com scp prod:/tmp/$DUMP .
26 3fb150de Jérôme Schneider
    scp calebasse.aps42.entrouvert.com:$DUMP .
27 2a56d9e8 Jérôme Schneider
    ssh calebasse.aps42.entrouvert.com "rm /tmp/$DUMP"
28 3fb150de Jérôme Schneider
fi
29
30
bzip2 -dc ./last_dump.sql.bz2 | psql calebasse