Set archive command
Incremental backups require the use of archive files, and if you use barman for backup management, you need to give the archive files of each node tobarman to manage them.
• First, get the incoming directory of the node:
[antdb@antdb06 conf]$ barman show-server datanode_225m |grep incoming_wals_directory
incoming_wals_directory: /backup/antdb/barman/data//datanode_225m/incoming
• Set the node's archive command
Before setting the archive command, make sure the archive mode of the node is turned on.
• Standalone version: The administrator user logs in to the database and executes the following command:
alter system set archive_command='rsync -a %p antdb@kpantdb06:/backup/antdb/barman/data/datanode_225m/incoming/%f';
select pg_reload_conf();
• Cluster version: Log inadbmgr to modifyarchive_command.
set datanode master datanode_225m(archive_command='rsync -a %p antdb@kpantdb06:/backup/antdb/barman/data/datanode_225m/incoming/%f');
Follow the steps above to continue configuring other nodes.
If you are using the cluster version, because of the large number of nodes, scripts are provided later in this section to set the node's archive command in bulk.
Check the archive command for the nodes:
postgres=# show param datanode_225m archive_command;
type | status | message
-------------------------------+--------+---------------------------------------------------------------------------------------------------
datanode master datanode_225m | t | archive_command = rsync -a %p antdb@kpantdb06:/backup/antdb/barman/data/datanode_225m/incoming/%f
datanode slave datanode_225s | t | archive_command = rsync -a %p antdb@kpantdb06:/backup/antdb/barman/data/datanode_225s/incoming/%f
(2 rows)
Generate configuration files for all master node
After configuring the relevant parameters in the script, executesh barman-operate.sh generate_config to generate configuration files for all master nodes. After execution, check in the configuration file directory.
Set archive command for all master nodes
After the configuration file is checked, execute sh barman-operate.sh set_archive_cmd to set archive command for all master nodes. After execution, login to adbmgr and executeshow param nodename archive_command to check if the node's archive command is set correctly.
Forced Log Switch
After the configuration is complete, perform a log switch operation via barman to ensure that the nodes can be archived correctly:
barman switch-xlog --force --archive datanode_225m
Because there are many nodes in the cluster version, you can use barman switch-xlog --force --archive allto perform a log switch for all nodes.