Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Advantages and usage of pg_probackup in PostgreSql backup

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/02 Report--

This article shows you the advantages and usage of pg_probackup in PostgreSql backup. The content is concise and easy to understand. It will definitely brighten your eyes. I hope you can get something through the detailed introduction of this article.

There are many PostgreSql backup software (free), pgrman (written in a previous article), Barman (very powerful, very complex configuration). Recently, the official account of Wechat has released that the function of pg_probackup is similar to that of ORACLE rman.

Let's take a look at who pg_probackup is.

Pg_probackup is a free postgresql backup software, currently supported to postgresql 11, which is a backup tool developed by RU DEV developers. As a popular country to use postgresql, there are many related software (Japan, Russia).

This little brother is also famous for his other products, such as pg_pathman

The installation is very simple. I installed the little brother's repo.

Rpm-ivh http://repo.postgrespro.ru/pg_probackup/keys/pg_probackup-repo-centos.noarch.rpm

Yum install pg_probackup- {11,10,9.6,9.5}

So what are the advantages of this backup software over other backups?

1 you can choose full backup and incremental backup to speed up the backup of large libraries

2 automatic data consistency check and on-demand backup verification without actual data recovery

3 run backup, restore, and verification processes on multiple parallel threads

4 storing backup data in a compressed state to save disk space

5 backup from the standby server to avoid additional load on the primary server

6 Custom commands to simplify WAL log archiving

7 back up files and directories located outside the Postgres Pro data directory, such as configuration files or log files

Incremental backups will include the following ways

1 page backup. In this mode, pg_probackup scans all WAL files in the archive, starting with the last full or incremental backup. The newly created backup contains only the pages mentioned in the WAL record. This requires that all WAL files since the last backup appear in the WAL archive.

2 incremental backup. In this mode, pg_probackup reads all data files in the data directory and copies only the pages that have changed since the last backup. This mode does not require continuous archiving

3 PTRACK backup. In this mode, Postgres Pro dynamically tracks page changes. Its operation does not require continuous archiving. Whenever a relationship page is updated, the page is marked as a special PTRACK bitmap of the relationship. Because a page needs only one bit in PTRACK fork, such a bitmap is very small. Tracing means that there is some less overhead on database server operations, but incremental backups can be significantly faster.

It is important to note that the backup server and the restored server must be compatible with the block_size and wal_block_size parameters and have the same major version number.

After installing pg_probackup, the first thing to do is to initialize the backup directory

(the rpm package needs to be installed with the version number that needs to back up the database at the end of the execution program.)

Pg_probackup-11 init-B / pgdata/backup/

And the initialized data directory must be empty, otherwise an error will be reported. After initialization, the relevant directories will automatically generate wal and backup directories.

After initializing the directory, you need to initialize the instance that needs to be backed up, that is, the postgresql data directory of the current server, and give the current pg backup database a backup directory name.

Pg_probackup-11 add-instance-B / pgdata/backup/-D / pgdata/data/-- instance pg_test

There is one thing to note.

The backup directory must belong to the file system of the database server. The user who starts pg_probackup must have full access to the contents of the backup directory. If you specify the path to the backup directory in the BACKUP_PATH environment variable, you can ignore the option when running the pg_probackup command.

Archive_command needs to be changed in the configuration file

Archive_command = 'pg_probackup-11 archive-push-B / pgdata/backup-- instance pg_test-- wal-file-path% p-- wal-file-name% f'

Max_wal_senders = 10

Hot_standby = on

Full_page_writes = on

View configured backup files

Pg_probackup-11 show-config-B / pgdata/backup/-- instance pg_test

Execute the command directly below to back up the full backup of the test library

Pg_probackup-11 backup- B / pgdata/backup/-b full-- instance pg_test-d test-h 192.168.198.123-p 5432-U admin-w

After the completion of the full backup, you can also perform an incremental backup. If you do not want to enter a secret, you can perform a .pgpass secret-free operation.

Pg_probackup-11 backup- B / pgdata/backup/-b page-- instance pg_test-d test-h 192.168.198.123-p 5432-U admin-w

You can also view the history of backups.

Related post-backup verification can also be carried out.

At the same time, the retention period can be set for the data backed up in the directory.

Pg_probackup set-config-B / pgdata/backup/-- instance pg_test-- retention-redundancy 2-- retention-window 7

-- retention-redundancy=redundancy

How many days to keep the backup FULL

-- retention-window=window

How many days before the backup can be restored

Of course, there are many commands for pg_probackup, and the establishment of a centralized backup center (PG) can also be done through pg_probackup, such as setting up a backup machine (the disk is big enough).

Then set up backup directories for different PG databases, and backup and restore the data remotely.

At the same time, pg_probackup also supports paralle parallel data backup, which is faster.

You can also use autonomous to back up in some special cases

Automatic backups can be restored on servers that cannot access WAL archive.

Autonomous backups enable you to restore cluster state in a timely manner when WAL files are no longer available.

After all this is done, we can restore the database once.

Pg_probackup-11 restore-B / pgdata/backup/-- instance pg_test-- recovery-target-time='2019-10-14 23:33:1

After recovering the database, you may get an error if you start it immediately.

Directory permissions need to be reset to start the database normally

The above are the advantages and usage of pg_probackup in PostgreSql backup. Have you learned any knowledge or skills? If you want to learn more skills or enrich your knowledge reserve, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report