Postgresql database restoration time point based on archive logs

Source: Internet
Author: User
## 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.