Manual backup of PostgreSQL backup (Low level API)

Source: Internet
Author: User
Tags postgresql postgresql backup

First, backup1. Need to ensure that Archive_mode = on and Archive_command are valid2. Connect to the database on the master node and execute
SELECT pg_start_backup (' label ', true);

Pg_start_backup the benefit of setting the second parameter to TRUE is that the backup starts with a checkpoint, set to true to complete the checkpoint as soon as possible, and reduces the Wal file generated during the backup, but has an impact on the query, and the default setting of Checkpoint_ Completion_target half of the time, midnight backup suggested open

3. Copy the physical files elsewhere, compress them or transfer them to other places using other tools such as Nc,rsync.

Remove some files:

1) All log files under pg_log/can also be backed up together

2) All Wal files under pg_xlog/

3) All files under pg_xlog/archive_status/*

4) recovery.conf If you want to exclude backups from the library

5) Postmaster.pid, postmaster.opts

4. When you are done copying, connect the database execution
SELECT Pg_stop_backup ();
Second, recovery1. CONVERT (unzip or copy) the backup to the data directory to be recovered2. Prepare recovery.conf
Recovery_target_time= ' 2015-08-04 12:00:00+8 ' #需要恢复到的时间点pause_at_recovery_target =true #到恢复目标后暂停recovery_targ         Et_inclusive=false #到恢复目标后是否停止恢复, set to True to rename recovery.conf to recovery.donerestore_command= ' cp/data/xlog/%f%p ' #wal文件归档的位置, you must specify

Standby_mode = ' on ' cannot be set, Recovery_target_time needs to be restored to the specified transaction ID and specified backup location after the underlying backup, see: http://www.postgresql.org/docs/ 9.4/static/recovery-target-settings.html#recovery-target-inclusive

3. Start the BACKUP Database
pg_ctl-d/data/restore_data Start

Reference: http://www.postgresql.org/docs/9.4/interactive/continuous-archiving.html

Manual backup of PostgreSQL backup (Low level API)

Related Article

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.