Project

General

Profile

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

calebasse / reinit-psql.sh @ feffc421

1
#!/bin/bash
2

    
3
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
if [ $# -gt 0 ]; then
12
    if [ "$1" != "new" -a "$1" != "dl" ]; then
13
        echo $HELP
14
        exit 1
15
    fi
16
fi
17

    
18
sudo -u postgres dropdb calebasse
19
sudo -u postgres createdb calebasse -O $USER
20

    
21
if [ $# -gt 0 ]; then
22
    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
    scp calebasse.aps42.entrouvert.com:$DUMP .
27
    ssh calebasse.aps42.entrouvert.com "rm /tmp/$DUMP"
28
fi
29

    
30
bzip2 -dc ./last_dump.sql.bz2 | psql calebasse
(12-12/15)