Project

General

Profile

« Previous | Next » 

Revision 8928

Added by Jing Tao over 9 years ago

Fixed some bugs to restore postgresql data.

View differences:

restore-dumped-data-to-pg9.3.sh
37 37
DECOMPRESS_DIR_NAME=`echo "$METACAT_BACKUP_FILE_NAME" | cut -d'.' -f1`
38 38
echo "the decmporessed dir is $DECOMPRESS_DIR_NAME"
39 39

  
40
echo "back up the old db data at $OLD_DB_DATA_DIR"
41
su - $POSTGRES_USER -c "tar -zcvf $DB_BASE/$OLD_DB_BACKUP_FILE $OLD_DB_DATA_DIR"
40
if [ -f "$DB_BASE/$OLD_DB_BACKUP_FILE" ]; then
41
        echo "$DB_BASE/$OLD_DB_BACKUP_FILE does exist and we don't need to backup it again"   
42
else
43
	echo "back up the old db data at $OLD_DB_DATA_DIR"
44
        su - $POSTGRES_USER -c "tar -zcvf $DB_BASE/$OLD_DB_BACKUP_FILE $OLD_DB_DATA_DIR"
45
	echo "delete the data directory - $OLD_DB_DATA_DIR"
46
	rm -rf $OLD_DB_DATA_DIR
47
fi
42 48

  
43 49
echo "stop postgresql"
44 50
/etc/init.d/postgresql stop
......
50 56
echo "modify the port to 5432 in the new db configuration file"
51 57
sed -i.bak --regexp-extended "s/(port =).*/\1${PORT}/;" $NEW_DB_CONFIG
52 58

  
53
echo "delete the data directory of 8.4"
54
rm -rf $OLD_DB_DATA_DIR
59
if [ -d "$METACAT_BACKUP_DIR/$DECOMPRESS_DIR_NAME" ]; then
60
        echo "$METACAT_BACKUP_DIR/$DECOMPRESS_DIR_NAME does exist and we don't need to decompress the metacat backup file again"   
61
else
62
	echo "decompress the metacat backup file"
63
	tar zxvf $METACAT_BACKUP_DIR/$METACAT_BACKUP_FILE_NAME -C $METACAT_BACKUP_DIR
64
fi
55 65

  
56
echo "decompress the metacat backup file"
57
tar zxvf $METACAT_BACKUP_DIR/$METACAT_BACKUP_FILE_NAM -C $METACAT_BACKUP_DIR
66
echo "restart postgresql"
67
/etc/init.d/postgresql start
58 68

  
59 69
echo "restore database"
60
su - POSTGRES_USER -c "psql -f $METACAT_BACKUP_DIR/$DECOMPRESS_DIR_NAME/$SQL_FILE postgres"
70
su - $POSTGRES_USER -c "psql -f $METACAT_BACKUP_DIR/$DECOMPRESS_DIR_NAME/$SQL_FILE postgres"
61 71

  
62 72
echo "end to move database from $OLD_DB_VERSION to $NEW_DB_VERSION at"
63 73
echo `date`

Also available in: Unified diff