Postgres在线备份步骤:
1.在线备份数据库:
[postgres@localhost~]$ vi .bash_profile
exportPGDATA=$HOME/pgdata
export BACKBASE=/home/postgres/wmpay_bak
exportARCHIVE=/home/postgres/wmpay_archive_log
[postgres@localhost~]$ psql -d wmpay -c "select PG_START_BACKUP('backup baseline')"
pg_start_backup
-----------------
0/4C51EC
(1 row)
[postgres@localhostwmpay_archive_log]$ cp -R $PGDATA/* $BACKBASE
[postgres@localhostwmpay_archive_log]$ psql -d wmpay -c "select PG_STOP_BACKUP()"
pg_stop_backup
----------------
0/4C5248
(1 row)
######################################################################################
#[postgres@localhost~]$ cd wmpay_archive_log/
#[postgres@localhostwmpay_archive_log]$ ls
#000000010000000000000000 000000010000000000000002
#000000010000000000000000.004C51EC.backup archive_status
#000000010000000000000001
#[postgres@localhostwmpay_archive_log]$ more 000000010000000000000000.004C51EC.backup
#START WAL LOCATION:0/4C51EC (file 000000010000000000000000)
#STOP WAL LOCATION:0/4C5248 (file 000000010000000000000000)
#CHECKPOINTLOCATION: 0/4C51EC
#START TIME:2013-05-11 00:01:31 CST
#LABEL: backupbaseline
#STOP TIME:2013-05-11 00:19:37 CST
######################################################################################
2.备份在线日志:
cp -R$PGDATA/pg_xlog/* $ARCHIVE