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)