Revision 9011
Added by Jing Tao almost 10 years ago
src/scripts/bash/restore-dumped-data-to-pg9.3.sh | ||
---|---|---|
19 | 19 |
ANOTHER_OLD_DB_VERSION=9.1 |
20 | 20 |
NEW_DB_VERSION=9.3 |
21 | 21 |
NEW_DB_CONFIG=/etc/postgresql/$NEW_DB_VERSION/main/postgresql.conf |
22 |
OLD_DB_CONFIG=/etc/postgresql/$OLD_DB_VERSION/main/postgresql.conf |
|
22 | 23 |
OLD_DB_DATA_DIR=$DB_BASE/$OLD_DB_VERSION |
23 | 24 |
OLD_DB_BACKUP_FILE=postgresql-$OLD_DB_VERSION.tar.gz |
24 | 25 |
POSTGRES_USER=postgres |
25 | 26 |
PORT=5432 |
27 |
PORT1=5435 |
|
26 | 28 |
echo "start to move database from $OLD_DB_VERSION to $NEW_DB_VERSION at" |
27 | 29 |
echo `date` |
28 | 30 |
|
... | ... | |
59 | 61 |
else |
60 | 62 |
echo "back up the old db data at $OLD_DB_DATA_DIR" |
61 | 63 |
su - $POSTGRES_USER -c "tar -zcvf $DB_BASE/$OLD_DB_BACKUP_FILE $OLD_DB_DATA_DIR" |
62 |
echo "delete the data directory - $OLD_DB_DATA_DIR" |
|
63 |
rm -rf $OLD_DB_DATA_DIR/main/* |
|
64 |
#echo "delete the data directory - $OLD_DB_DATA_DIR"
|
|
65 |
#rm -rf $OLD_DB_DATA_DIR/main/*
|
|
64 | 66 |
fi |
65 | 67 |
|
66 |
echo "remove postgresql 8.4 and 9.1" |
|
68 |
#echo "remove postgresql 8.4 and 9.1"
|
|
67 | 69 |
|
68 |
apt-get -y remove postgresql-$OLD_DB_VERSION |
|
69 |
apt-get -y remove postgresql-$ANOTHER_OLD_DB_VERSION |
|
70 |
#apt-get -y remove postgresql-$OLD_DB_VERSION
|
|
71 |
#apt-get -y remove postgresql-$ANOTHER_OLD_DB_VERSION
|
|
70 | 72 |
|
73 |
echo "modify the port to 5435 in the old new db configuraiton file" |
|
74 |
sed -i.bak --regexp-extended "s/(port =).*/\1${PORT1}/;" $OLD_DB_CONFIG |
|
75 |
|
|
71 | 76 |
echo "modify the port to 5432 in the new db configuration file" |
72 | 77 |
sed -i.bak --regexp-extended "s/(port =).*/\1${PORT}/;" $NEW_DB_CONFIG |
73 | 78 |
|
Also available in: Unified diff
Don't remove postgresql 8.4 and 9.1
Don't remove data directory of postgresql 8.4