主题
sh
#! /bin/bash
HS_HOME=/home/centos/workspace/hengshi-java/hengshi
PG_HOME=$HS_HOME/lib/pgsql
export PATH=$PATH:$PG_HOME/bin
PG_USR=postgres
PG_PWD=postgres
PG_HOST=127.0.0.1
PG_PORT=5434
# ------------ meta ------------
backup_meta() {
local dbname="$1"
echo "PGPASSOWRD=$PG_PWD pg_dump -U$PG_USR -h$PG_HOST -p$PG_PORT $dbname > $dbname.backup.sql"
PGPASSOWRD=$PG_PWD pg_dump -U$PG_USR -h$PG_HOST -p$PG_PORT $dbname > $dbname.backup.sql
}
# ------ engine ------------
ENGINE_HOME=$HS_HOME/engine-cluster
backup_engine() {
source $ENGINE_HOME/export-cluster.sh
echo "engine: pg_dumpall"
pg_dumpall > engine.back.sql
}
# ------- run -----------
backup_meta postgres
backup_meta hengshi_sense_internal_storage
backup_engine
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30