## Mvusrlocalpostrgresql-8.4.14d
Postgresql database restore time point based on archive logs 1. Postgresql database restore www.2cto.com Based on archive logs 1. Back up the running data DIRECTORY # mv data data_bak 2. decompress the full backup to the data directory the day before yesterday # tar-zxvf fullbackup20121031.tar.gz # mv usr/local/postrgresql-8.4.14/d
Postgresql database restoration time point based on archive logs
I. Restoring Postgresql databases based on archived logs
Www.2cto.com
1. Backup data Directory
# Mv data data_bak
2. Decompress all backup files from the previous day to the data directory.
# Tar-zxvf fullbackup20121031.tar.gz
# Mv usr/local/postrgresql-8.4.14/data // usr/local/postrgresql-8.4.14/
3. Clear the postmaster. pid file.
# Rm postmaster. pid
4. Create the pg_xlog directory and pg_xlog/archive_status (note that the permission is ipvs)
Cd/usr/local/postrgresql-8.4.14/data
Mkdir-p pg_xlog/archive_status
5. copy the files in the backup pg_xlog to the data/pg_xlog directory.
# Cp-a data_bak/pg_xlog/0 * data/pg_xlog/
6. Copy the recovery. conf file to the DATA directory and specify the recovery time point.
# Cp/usr/local/postrgresql-8.4.14/share/postgresql/recovery. conf. sample data/recovery. conf
# Modifying the recovery. conf file,
Restore_command = 'cp/backup/wals/% f % P' // archive log directory
Recovery_target_time = '2017-10-31 11:41:50 '// specify the archiving time point. If the last transaction completed before the fault is not specified
7. Start the database
/Etc/init. d/postgresql-8.4 start
8. view database logs
# Tail-f postgresql-2012-10-31_121721.csv
...........
Last completed transaction was at log time 11:40:12. 353374 + 08 "/the last committed transaction at the specified time point
Archive recovery complete ", // The archived log has been restored.
Database system is ready to accept connections // the database can be connected