Manager Handbook for Distributed AntDB-T - P20–2
Published: 2023-08-23 04:15:26

Global configuration file
The detailed parameters of the configuration file can be found in the documentationadb-barma-master/doc/barman.conf in the source code directory.
vi ~/.barman.conf

```
[barman] 
barman_user = antdb 
configuration_files_directory = /backup/antdb/barman/conf/ 
barman_home = /backup/antdb/barman/data/ 
log_file = /backup/antdb/barman/log/barman.log 
compression = gzip 
parallel_jobs =3 
minimum_redundancy = 1 
retention_policy = RECOVERY WINDOW OF 1 WEEKS 
reuse_backup = link 
```

The following parameters need to be modified as appropriate.
•Barman_user: The user who runs the barman program
•configuration_files_directory: The directory where the configuration files of the node are stored
•barman_home: The directory where the backup data of the node is stored
•log_file: The main log file of the barman program.
•minimum_redundancy: Minimum number of backups to keep
•retention_policy: Retention policy for backup data
Configuration file for backing up nodes
Usually, it is necessary to back up the coordinator master, gtmcoord master and datanode maste nodes in the cluster, and the example of configuration file is as follows:

```
[antdb@antdb06 conf]$ cat datanode_225m.conf 
[datanode_225m] 
description =  "datanode master  datanode_225m" 
ssh_command = ssh antdb@134.78.9.256 -q 
conninfo = host=134.78.9.256 port=24330 user=antdb dbname=postgres 
backup_method = rsync 
backup_options = exclusive_backup 
parallel_jobs = 3 
archiver = on 
archiver_batch_size = 50 

```
It is recommended that the configuration file's文件名, the [] identification in the file content, and the nodename in adbmgr are kept consistent for easy identification.
•If you use the cluster version, because there are many nodes, scripts are provided later in this section to generate the configuration files of the masternodes in bulk.
•If you use the standalone version, you can directly edit the node configuration files.
•With the same parameters, the node configuration will override the global configuration.
Check the node configuration
After checking the configuration files of the nodes by barman check nodename, a folder named after the node name is produced in the data directory of barman:

```
[antdb@kpantdb06 data]$ barman check datanode_225m 
Server datanode_225m: 
        PostgreSQL: OK 
        is_superuser: OK 
        wal_level: OK 
        directories: OK 
        retention policy settings: OK 
        backup maximum age: OK (no last_backup_maximum_age provided) 
        compression settings: OK 
        failed backups: OK (there are 0 failed backups) 
        minimum redundancy requirements: FAILED (have 0 backups, expected at least 1) 
        ssh: OK (PostgreSQL server) 
        not in recovery: OK 
        archive_mode: OK 
        archive_command: OK 
        continuous archiving: OK 
        archiver errors: OK 
[antdb@kpantdb06 data]$ ll datanode_225m 
total 192 
drwxrwxr-x 2 antdb antdb     10 Dec 24 21:14 base 
drwxrwxr-x 2 antdb antdb     10 Dec 24 21:14 errors 
drwxrwxr-x 2 antdb antdb 135168 Dec 25 10:41 incoming 
drwxrwxr-x 2 antdb antdb     10 Dec 24 21:14 streaming 
drwxrwxr-x 3 antdb antdb     57 Dec 24 21:24 wals 
[antdb@kpantdb06 data]$  
```
Cluster versions with more nodes can perform a check of all nodes by barman check all.
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) 
```