Barman backup

713 views
Skip to first unread message

Kiran Kumar Jadaprolu

unread,
Sep 17, 2020, 6:18:58 AM9/17/20
to Barman, Backup and Recovery Manager for PostgreSQL
Hi All,

I am new to postgresql. Today I received a task to configure backup using barman.

I have done everything. But when I am trying to take backup I am unable to find my directories related to all databases in backup directory.

Please help me.

Kiran Kumar Jadaprolu

unread,
Sep 17, 2020, 6:24:02 AM9/17/20
to Barman, Backup and Recovery Manager for PostgreSQL
barman diagnose output:

{
    "global": {
        "config": {
            "backup_options": "concurrent_backup",
            "barman_home": "/var/lib/barman",
            "barman_user": "barman",
            "basebackup_retry_sleep": "30",
            "basebackup_retry_times": "3",
            "compression": "gzip",
            "configuration_files_directory": "/etc/barman.d",
            "errors_list": [],
            "immediate_checkpoint": "true",
            "log_file": "/var/log/barman/barman.log",
            "reuse_backup": "off"
        },
        "system_info": {
            "barman_ver": "2.11",
            "kernel_ver": "Linux barman-Server 4.4.0-189-generic #219-Ubuntu SMP Tue Aug 11 12:26:50 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux",
            "python_ver": "",
            "release": "Distributor ID:\tUbuntu\nDescription:\tUbuntu 16.04.6 LTS\nRelease:\t16.04\nCodename:\txenial",
            "rsync_ver": "rsync  version 3.1.1  protocol version 31",
            "ssh_ver": "",
            "timestamp": "Thu Sep 17 15:38:39 2020"
        }
    },
    "servers": {
        "PostgreSQL-Primary": {
            "backups": {
                "20200917T151958": {
                    "backup_id": "20200917T151958",
                    "backup_label": "'START WAL LOCATION: 7/23000028 (file 000000010000000700000023)\\nCHECKPOINT LOCATION: 7/23000060\\nBACKUP METHOD: streamed\\nBACKUP FROM: master\\nSTART TIME: 2020-09-17 15:19:58 IST\\nLABEL: Barman backup PostgreSQL-Primary 20200917T151958\\nSTART TIMELINE: 1\\n'",
                    "begin_offset": 40,
                    "begin_time": "Thu Sep 17 15:19:58 2020",
                    "begin_wal": "000000010000000700000023",
                    "begin_xlog": "7/23000028",
                    "config_file": "/etc/postgresql/12/main/postgresql.conf",
                    "copy_stats": {
                        "analysis_time": 2.154462,
                        "analysis_time_per_item": {
                            "pgdata": 1.010321,
                            "samplets": 1.144101
                        },
                        "copy_time": 3.935731,
                        "copy_time_per_item": {
                            "config_file": 0.450589,
                            "hba_file": 0.543421,
                            "ident_file": 0.457584,
                            "pg_control": 0.485417,
                            "pgdata": 1.028091,
                            "samplets": 0.960798
                        },
                        "number_of_workers": 1,
                        "serialized_copy_time": 3.92174,
                        "serialized_copy_time_per_item": {
                            "config_file": 0.450589,
                            "hba_file": 0.543421,
                            "ident_file": 0.457584,
                            "pg_control": 0.485417,
                            "pgdata": 1.02626,
                            "samplets": 0.958469
                        },
                        "total_time": 6.131586
                    },
                    "deduplicated_size": 747705,
                    "end_offset": 312,
                    "end_time": "Thu Sep 17 15:20:05 2020",
                    "end_wal": "000000010000000700000023",
                    "end_xlog": "7/23000138",
                    "error": null,
                    "hba_file": "/etc/postgresql/12/main/pg_hba.conf",
                    "ident_file": "/etc/postgresql/12/main/pg_ident.conf",
                    "included_files": null,
                    "mode": "rsync-concurrent",
                    "pgdata": "/var/lib/postgresql/12/main",
                    "server_name": "PostgreSQL-Primary",
                    "size": 747705,
                    "status": "DONE",
                    "systemid": "6851520378512605282",
                    "tablespaces": [
                        [
                            "samplets",
                            16386,
                            "/var/lib/postgresql/12/main/base"
                        ]
                    ],
                    "timeline": 1,
                    "version": 120003,
                    "xlog_segment_size": 16777216
                },
                "20200917T153039": {
                    "backup_id": "20200917T153039",
                    "backup_label": "'START WAL LOCATION: 7/25000028 (file 000000010000000700000025)\\nCHECKPOINT LOCATION: 7/25000060\\nBACKUP METHOD: streamed\\nBACKUP FROM: master\\nSTART TIME: 2020-09-17 15:30:39 IST\\nLABEL: Barman backup PostgreSQL-Primary 20200917T153039\\nSTART TIMELINE: 1\\n'",
                    "begin_offset": 40,
                    "begin_time": "Thu Sep 17 15:30:39 2020",
                    "begin_wal": "000000010000000700000025",
                    "begin_xlog": "7/25000028",
                    "config_file": "/etc/postgresql/12/main/postgresql.conf",
                    "copy_stats": {
                        "analysis_time": 2.182322,
                        "analysis_time_per_item": {
                            "pgdata": 1.047851,
                            "samplets": 1.1344
                        },
                        "copy_time": 3.955779,
                        "copy_time_per_item": {
                            "config_file": 0.457936,
                            "hba_file": 0.501188,
                            "ident_file": 0.51162,
                            "pg_control": 0.516362,
                            "pgdata": 0.976848,
                            "samplets": 0.980091
                        },
                        "number_of_workers": 1,
                        "serialized_copy_time": 3.940943,
                        "serialized_copy_time_per_item": {
                            "config_file": 0.457936,
                            "hba_file": 0.501188,
                            "ident_file": 0.51162,
                            "pg_control": 0.516362,
                            "pgdata": 0.97506,
                            "samplets": 0.978777
                        },
                        "total_time": 6.246439
                    },
                    "deduplicated_size": 747705,
                    "end_offset": 256,
                    "end_time": "Thu Sep 17 15:30:45 2020",
                    "end_wal": "000000010000000700000025",
                    "end_xlog": "7/25000100",
                    "error": null,
                    "hba_file": "/etc/postgresql/12/main/pg_hba.conf",
                    "ident_file": "/etc/postgresql/12/main/pg_ident.conf",
                    "included_files": null,
                    "mode": "rsync-concurrent",
                    "pgdata": "/var/lib/postgresql/12/main",
                    "server_name": "PostgreSQL-Primary",
                    "size": 747705,
                    "status": "DONE",
                    "systemid": "6851520378512605282",
                    "tablespaces": [
                        [
                            "samplets",
                            16386,
                            "/var/lib/postgresql/12/main/base"
                        ]
                    ],
                    "timeline": 1,
                    "version": 120003,
                    "xlog_segment_size": 16777216
                },
                "20200917T153245": {
                    "backup_id": "20200917T153245",
                    "backup_label": "'START WAL LOCATION: 7/27000028 (file 000000010000000700000027)\\nCHECKPOINT LOCATION: 7/27000060\\nBACKUP METHOD: streamed\\nBACKUP FROM: master\\nSTART TIME: 2020-09-17 15:32:45 IST\\nLABEL: Barman backup PostgreSQL-Primary 20200917T153245\\nSTART TIMELINE: 1\\n'",
                    "begin_offset": 40,
                    "begin_time": "Thu Sep 17 15:32:45 2020",
                    "begin_wal": "000000010000000700000027",
                    "begin_xlog": "7/27000028",
                    "config_file": "/etc/postgresql/12/main/postgresql.conf",
                    "copy_stats": {
                        "analysis_time": 2.332771,
                        "analysis_time_per_item": {
                            "pgdata": 1.121059,
                            "samplets": 1.211641
                        },
                        "copy_time": 3.985522,
                        "copy_time_per_item": {
                            "config_file": 0.476957,
                            "hba_file": 0.444247,
                            "ident_file": 0.529685,
                            "pg_control": 0.529066,
                            "pgdata": 0.993731,
                            "samplets": 0.998386
                        },
                        "number_of_workers": 1,
                        "serialized_copy_time": 3.966251,
                        "serialized_copy_time_per_item": {
                            "config_file": 0.476957,
                            "hba_file": 0.444247,
                            "ident_file": 0.529685,
                            "pg_control": 0.529066,
                            "pgdata": 0.990649,
                            "samplets": 0.995647
                        },
                        "total_time": 6.36435
                    },
                    "deduplicated_size": 747705,
                    "end_offset": 312,
                    "end_time": "Thu Sep 17 15:32:51 2020",
                    "end_wal": "000000010000000700000027",
                    "end_xlog": "7/27000138",
                    "error": null,
                    "hba_file": "/etc/postgresql/12/main/pg_hba.conf",
                    "ident_file": "/etc/postgresql/12/main/pg_ident.conf",
                    "included_files": null,
                    "mode": "rsync-concurrent",
                    "pgdata": "/var/lib/postgresql/12/main",
                    "server_name": "PostgreSQL-Primary",
                    "size": 747705,
                    "status": "DONE",
                    "systemid": "6851520378512605282",
                    "tablespaces": [
                        [
                            "samplets",
                            16386,
                            "/var/lib/postgresql/12/main/base"
                        ]
                    ],
                    "timeline": 1,
                    "version": 120003,
                    "xlog_segment_size": 16777216
                }
            },
            "config": {
                "active": true,
                "archiver": true,
                "archiver_batch_size": 0,
                "backup_directory": "/var/lib/barman/PostgreSQL-Primary",
                "backup_method": "rsync",
                "backup_options": "concurrent_backup",
                "bandwidth_limit": null,
                "barman_home": "/var/lib/barman",
                "barman_lock_directory": "/var/lib/barman",
                "basebackup_retry_sleep": 30,
                "basebackup_retry_times": 3,
                "basebackups_directory": "/var/lib/barman/PostgreSQL-Primary/base",
                "check_timeout": 30,
                "compression": "gzip",
                "conninfo": "host=192.168.0.108 user=postgres port=5432 password=*REDACTED*",
                "create_slot": "manual",
                "custom_compression_filter": null,
                "custom_decompression_filter": null,
                "description": "Main DB Server",
                "disabled": false,
                "errors_directory": "/var/lib/barman/PostgreSQL-Primary/errors",
                "immediate_checkpoint": true,
                "incoming_wals_directory": "/var/lib/barman/PostgreSQL-Primary/incoming",
                "last_backup_maximum_age": null,
                "max_incoming_wals_queue": null,
                "minimum_redundancy": 0,
                "msg_list": [],
                "name": "PostgreSQL-Primary",
                "network_compression": false,
                "parallel_jobs": 1,
                "path_prefix": null,
                "post_archive_retry_script": null,
                "post_archive_script": null,
                "post_backup_retry_script": null,
                "post_backup_script": null,
                "post_delete_retry_script": null,
                "post_delete_script": null,
                "post_recovery_retry_script": null,
                "post_recovery_script": null,
                "post_wal_delete_retry_script": null,
                "post_wal_delete_script": null,
                "pre_archive_retry_script": null,
                "pre_archive_script": null,
                "pre_backup_retry_script": null,
                "pre_backup_script": null,
                "pre_delete_retry_script": null,
                "pre_delete_script": null,
                "pre_recovery_retry_script": null,
                "pre_recovery_script": null,
                "pre_wal_delete_retry_script": null,
                "pre_wal_delete_script": null,
                "primary_ssh_command": null,
                "recovery_options": "",
                "retention_policy": null,
                "retention_policy_mode": "auto",
                "reuse_backup": "off",
                "slot_name": null,
                "ssh_command": "ssh post...@192.168.0.108",
                "streaming_archiver": false,
                "streaming_archiver_batch_size": 0,
                "streaming_archiver_name": "barman_receive_wal",
                "streaming_backup_name": "barman_streaming_backup",
                "streaming_conninfo": "host=192.168.0.108 user=postgres port=5432 password=*REDACTED*",
                "streaming_wals_directory": "/var/lib/barman/PostgreSQL-Primary/streaming",
                "tablespace_bandwidth_limit": null,
                "wal_retention_policy": "main",
                "wals_directory": "/var/lib/barman/PostgreSQL-Primary/wals"
            },
            "status": {
                "archive_command": "test ! -f barman@barman-Server:/var/lib/barman/PostgreSQL-Primary/incoming/%f && rsync -a %p barman@barman-Server:/var/lib/barman/PostgreSQL-Primary/incoming/%f",
                "archive_mode": "on",
                "archive_timeout": 0,
                "archived_count": 217,
                "checkpoint_timeout": 300,
                "config_file": "/etc/postgresql/12/main/postgresql.conf",
                "current_archived_wals_per_second": 0.0014255532789181299,
                "current_lsn": "7/280001B0",
                "current_size": 947771515.0,
                "current_xlog": "000000010000000700000028",
                "data_checksums": "off",
                "data_directory": "/var/lib/postgresql/12/main",
                "failed_count": 0,
                "has_backup_privileges": true,
                "hba_file": "/etc/postgresql/12/main/pg_hba.conf",
                "hot_standby": "on",
                "ident_file": "/etc/postgresql/12/main/pg_ident.conf",
                "is_archiving": true,
                "is_in_recovery": false,
                "is_superuser": true,
                "last_archived_time": "Thu Sep 17 15:32:53 2020",
                "last_archived_wal": "000000010000000700000027.00000028.backup",
                "last_failed_time": null,
                "last_failed_wal": null,
                "max_replication_slots": "2",
                "max_wal_senders": "2",
                "pgespresso_installed": false,
                "postgres_systemid": "6851520378512605282",
                "replication_slot": null,
                "replication_slot_support": true,
                "server_txt_version": "12.3",
                "stats_reset": "Tue Sep 15 21:21:40 2020",
                "synchronous_standby_names": [
                    ""
                ],
                "wal_compression": "off",
                "wal_keep_segments": "0",
                "wal_level": "replica",
                "xlog_segment_size": 16777216
            },
            "system_info": {
                "kernel_ver": "Linux PostgreSQL-Primary 5.3.0-64-generic #58-Ubuntu SMP Fri Jul 10 19:33:51 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux",
                "python_ver": "",
                "release": "Distributor ID:\tUbuntu\nDescription:\tUbuntu 19.10\nRelease:\t19.10\nCodename:\teoan",
                "rsync_ver": "rsync  version 3.1.3  protocol version 31",
                "ssh_ver": ""
            },
            "wals": {
                "last_archived_wal_per_timeline": {
                    "00000001": {
                        "compression": "gzip",
                        "name": "000000010000000700000027",
                        "size": 16480,
                        "time": 1600336971.9291441
                    }
                }
            }
        }
    }
}


=
=====================

My barman version is 2.11
PostgreSQL version: 12


Muhammad Amer Siddique

unread,
Sep 17, 2020, 6:30:42 AM9/17/20
to pgba...@googlegroups.com
HI Kiran, 

The best way to understand barman is to go through documentation.  https://docs.pgbarman.org/release/2.11/barman.5.html 

Following commands might alo help with what you are trying to achieve. 

Barman list backup  -- Will provide backup information
Barman list-files [OPTIONS] SERVER_NAME BACKUP_ID Will provide you details of files in backup.  

Regards, Amer


--
--
You received this message because you are subscribed to the "Barman for PostgreSQL" group.
To post to this group, send email to pgba...@googlegroups.com
To unsubscribe from this group, send email to
pgbarman+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/pgbarman?hl=en?hl=en-GB

---
You received this message because you are subscribed to the Google Groups "Barman, Backup and Recovery Manager for PostgreSQL" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pgbarman+u...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/pgbarman/6a480b35-4f0a-4140-8e6e-94b61ad5ece3n%40googlegroups.com.

Kiran Kumar Jadaprolu

unread,
Sep 17, 2020, 6:40:23 AM9/17/20
to Barman, Backup and Recovery Manager for PostgreSQL
Thanks for quick response Amer.

barman@barman-Server:~$ barman list-backup PostgreSQL-Primary
PostgreSQL-Primary 20200917T153245 - Thu Sep 17 15:32:51 2020 - Size: 746.3 KiB - WAL Size: 0 B (tablespaces: samplets:/var/lib/postgresql/12/main/base)
PostgreSQL-Primary 20200917T153039 - Thu Sep 17 15:30:45 2020 - Size: 746.3 KiB - WAL Size: 32.2 KiB (tablespaces: samplets:/var/lib/postgresql/12/main/base)
PostgreSQL-Primary 20200917T151958 - Thu Sep 17 15:20:05 2020 - Size: 746.3 KiB - WAL Size: 32.2 KiB (tablespaces: samplets:/var/lib/postgresql/12/main/base)

I checked the backup location size it is very minimum and I try to restore in another server where I am unable to see database directories under base directory.

I used the below command for backup:

barman backup PostgreSQL-Primary
 
Backup completed successfully. My actual DB size is 1GB but backup location size is very less.

Regards,
Kiran

Muhammad Amer Siddique

unread,
Sep 17, 2020, 6:45:46 AM9/17/20
to pgba...@googlegroups.com
Could you please check the restore logs ?



Kiran Kumar Jadaprolu

unread,
Sep 17, 2020, 6:54:58 AM9/17/20
to Barman, Backup and Recovery Manager for PostgreSQL
Hi Amer,

This my Primary DB layout files in base directory:

postgres@PostgreSQL-Primary:~/12/main/base$ ls -ltr
total 60
drwx------ 2 postgres postgres  4096 Jul 20 16:48 13441
drwx------ 2 postgres postgres  4096 Aug 26 20:11 pgsql_tmp
drwx------ 3 postgres postgres  4096 Sep  9 20:01 PG_12_201909212
drwx------ 2 postgres postgres 12288 Sep 14 20:13 73753
drwx------ 2 postgres postgres 12288 Sep 17 13:06 1
drwx------ 2 postgres postgres 12288 Sep 17 13:06 73752
drwx------ 2 postgres postgres 12288 Sep 17 13:07 13442


in Target:

postgres@PostgreSQL-Secondary:~/12/main/base$ pwd
/var/lib/postgresql/12/main/base
postgres@PostgreSQL-Secondary:~/12/main/base$ ls -ltr
total 4
drwx------ 2 postgres postgres 4096 Sep  9 20:01 PG_12_201909212
postgres@PostgreSQL-Secondary:~/12/main/base$

I have verified in my barman.log:

Copying backup files to terget server completed soon. 

2020-09-17 16:18:23,736 [4028] barman.copy_controller INFO: Copy started (safe before datetime.datetime(2020, 9, 17, 14, 51, 39, 269070, tzinfo=tzoffset(None, 19800)))
2020-09-17 16:18:23,737 [4028] barman.copy_controller INFO: Copy step 1 of 8: [global] analyze tablespace directory 'samplets': /var/lib/barman/PostgreSQL-Primary/base/20200917T151958/16386/
2020-09-17 16:18:24,455 [4028] barman.copy_controller INFO: Copy step 2 of 8: [global] create destination directories and delete unknown files for tablespace directory 'samplets': /var/lib/barman/PostgreSQL-Primary/base/20200917T151958/16386/
2020-09-17 16:18:25,059 [4028] barman.copy_controller INFO: Copy step 3 of 8: [global] analyze PGDATA directory: /var/lib/barman/PostgreSQL-Primary/base/20200917T151958/data/
2020-09-17 16:18:25,790 [4028] barman.copy_controller INFO: Copy step 4 of 8: [global] create destination directories and delete unknown files for PGDATA directory: /var/lib/barman/PostgreSQL-Primary/base/20200917T151958/data/
2020-09-17 16:18:26,421 [4092] barman.copy_controller INFO: Copy step 5 of 8: [bucket 0] starting copy safe files from tablespace directory 'samplets': /var/lib/barman/PostgreSQL-Primary/base/20200917T151958/16386/
2020-09-17 16:18:27,081 [4092] barman.copy_controller INFO: Copy step 5 of 8: [bucket 0] finished (duration: less than one second) copy safe files from tablespace directory 'samplets': /var/lib/barman/PostgreSQL-Primary/base/20200917T151958/16386/
2020-09-17 16:18:27,082 [4092] barman.copy_controller INFO: Copy step 6 of 8: [bucket 0] starting copy files with checksum from tablespace directory 'samplets': /var/lib/barman/PostgreSQL-Primary/base/20200917T151958/16386/
2020-09-17 16:18:27,734 [4092] barman.copy_controller INFO: Copy step 6 of 8: [bucket 0] finished (duration: less than one second) copy files with checksum from tablespace directory 'samplets': /var/lib/barman/PostgreSQL-Primary/base/20200917T151958/16386/
2020-09-17 16:18:27,737 [4092] barman.copy_controller INFO: Copy step 7 of 8: [bucket 0] starting copy safe files from PGDATA directory: /var/lib/barman/PostgreSQL-Primary/base/20200917T151958/data/
2020-09-17 16:18:28,439 [4092] barman.copy_controller INFO: Copy step 7 of 8: [bucket 0] finished (duration: less than one second) copy safe files from PGDATA directory: /var/lib/barman/PostgreSQL-Primary/base/20200917T151958/data/
2020-09-17 16:18:28,444 [4092] barman.copy_controller INFO: Copy step 8 of 8: [bucket 0] starting copy files with checksum from PGDATA directory: /var/lib/barman/PostgreSQL-Primary/base/20200917T151958/data/
2020-09-17 16:18:29,099 [4092] barman.copy_controller INFO: Copy step 8 of 8: [bucket 0] finished (duration: less than one second) copy files with checksum from PGDATA directory: /var/lib/barman/PostgreSQL-Primary/base/20200917T151958/data/
2020-09-17 16:18:29,101 [4028] barman.copy_controller INFO: Copy finished (safe before 2020-09-17 14:51:39.269070+05:30)
2020-09-17 16:18:29,827 [4028] barman.recovery_executor INFO: Copying required WAL segments.
2020-09-17 16:18:29,830 [4028] barman.recovery_executor INFO: Starting copy of 8 WAL files 8/8 from WalFileInfo(compression='gzip', name='000000010000000700000023', size=16479, time=1600336205.939015) to WalFileInfo(compression='gzip', name='000000010000000700000027.00000028.backup', size=227, time=1600336972.0051436)
2020-09-17 16:18:32,885 [4028] barman.recovery_executor INFO: Finished copying 8 WAL files.
2020-09-17 16:18:32,889 [4028] barman.recovery_executor INFO: Generating archive status files
2020-09-17 16:18:34,799 [4028] barman.recovery_executor INFO: Identify dangerous settings in destination directory.


Restoration command output:
========================

barman@barman-Server:~$ barman recover --remote-ssh-command "ssh postgres@PostgreSQL-Secondary"   PostgreSQL-Primary 20200917T151958 /var/lib/postgresql/12/main
Starting remote restore for server PostgreSQL-Primary using backup 20200917T151958
Destination directory: /var/lib/postgresql/12/main
Remote command: ssh postgres@PostgreSQL-Secondary
Using safe horizon time for smart rsync copy: 2020-09-17 14:51:39.269070+05:30
        16386, samplets, /var/lib/postgresql/12/main/base
Copying the base backup.
Copying required WAL segments.
Generating archive status files
Identify dangerous settings in destination directory.

IMPORTANT
These settings have been modified to prevent data losses

postgresql.conf line 233: archive_command = false

WARNING
You are required to review the following options as potentially dangerous

postgresql.conf line 40: data_directory = '/var/lib/postgresql/12/main'         # use data in another directory
postgresql.conf line 42: hba_file = '/etc/postgresql/12/main/pg_hba.conf'       # host-based authentication file
postgresql.conf line 44: ident_file = '/etc/postgresql/12/main/pg_ident.conf'   # ident configuration file
postgresql.conf line 48: external_pid_file = '/var/run/postgresql/12-main.pid'                  # write an extra PID file
postgresql.conf line 65: unix_socket_directories = '/var/run/postgresql'        # comma-separated list of directories
postgresql.conf line 101: ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem'
postgresql.conf line 103: ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key'
postgresql.conf line 740: include_dir = 'conf.d'                        # include files ending in '.conf' from

Recovery completed (start time: 2020-09-17 16:18:11.076641, elapsed time: 24 seconds)

Your PostgreSQL server has been successfully prepared for recovery!

Regards,
Kiran

Kiran Kumar Jadaprolu

unread,
Sep 17, 2020, 7:29:56 AM9/17/20
to Barman, Backup and Recovery Manager for PostgreSQL
This is the first time I am trying to use barman.

Does anyone tested barman 2.11 & PostgreSQL 12.

Part of POC I am trying this. Not at all happy with barman :(

Muhammad Amer Siddique

unread,
Sep 17, 2020, 8:27:04 AM9/17/20
to pgba...@googlegroups.com
COuld you please share contents of /var/lib/postgresql/12/main.

Kiran Kumar Jadaprolu

unread,
Sep 17, 2020, 8:48:39 AM9/17/20
to Barman, Backup and Recovery Manager for PostgreSQL
Hi Amer,

Source: 

postgres@PostgreSQL-Primary:~/12/main$ ls -ltr
total 84
-rwx------ 1 postgres postgres    3 Jul 20 16:48 PG_VERSION
drwx------ 2 postgres postgres 4096 Jul 20 16:48 pg_twophase
drwx------ 2 postgres postgres 4096 Jul 20 16:48 pg_stat_tmp
drwx------ 2 postgres postgres 4096 Jul 20 16:48 pg_snapshots
drwx------ 2 postgres postgres 4096 Jul 20 16:48 pg_serial
drwx------ 4 postgres postgres 4096 Jul 20 16:48 pg_multixact
drwx------ 2 postgres postgres 4096 Jul 20 16:48 pg_dynshmem
drwx------ 2 postgres postgres 4096 Jul 20 16:48 pg_commit_ts
-rwx------ 1 postgres postgres   88 Jul 20 16:48 postgresql.auto.conf
drwx------ 2 postgres postgres 4096 Jul 20 16:48 pg_xact
drwx------ 2 postgres postgres 4096 Aug  4 21:26 pg_tblspc
drwx------ 2 postgres postgres 4096 Sep  2 21:57 pg_subtrans
drwx------ 9 postgres postgres 4096 Sep 10 10:47 base
drwx------ 2 postgres postgres 4096 Sep 17 17:54 pg_notify
-rwx------ 1 postgres postgres  130 Sep 17 17:54 postmaster.opts
-rw------- 1 postgres postgres  101 Sep 17 17:54 postmaster.pid
drwx------ 2 postgres postgres 4096 Sep 17 17:54 pg_stat
drwx------ 2 postgres postgres 4096 Sep 17 17:55 global
drwx------ 2 postgres postgres 4096 Sep 17 18:07 pg_replslot
drwx------ 4 postgres postgres 4096 Sep 17 18:12 pg_logical
drwx------ 3 postgres postgres 4096 Sep 17 18:12 pg_wal

--> base directory contain database related directories.

Backup server:

barman@barman-Server:~/PostgreSQL-Primary/base/20200917T175521/data$ ls -ltr
total 116
-rwx------ 1 barman barman     3 Jul 20 16:48 PG_VERSION
drwx------ 2 barman barman  4096 Jul 20 16:48 pg_twophase
drwx------ 2 barman barman  4096 Jul 20 16:48 pg_stat_tmp
drwx------ 2 barman barman  4096 Jul 20 16:48 pg_snapshots
drwx------ 2 barman barman  4096 Jul 20 16:48 pg_serial
drwx------ 2 barman barman  4096 Jul 20 16:48 pg_replslot
drwx------ 4 barman barman  4096 Jul 20 16:48 pg_multixact
drwx------ 2 barman barman  4096 Jul 20 16:48 pg_dynshmem
drwx------ 2 barman barman  4096 Jul 20 16:48 pg_commit_ts
-rwx------ 1 barman barman    88 Jul 20 16:48 postgresql.auto.conf
drwx------ 2 barman barman  4096 Jul 20 16:48 pg_xact
-rw-r----- 1 barman barman  1636 Jul 20 16:48 pg_ident.conf
drwx------ 2 barman barman  4096 Sep  2 21:57 pg_subtrans
-rw-r----- 1 barman barman  4976 Sep 17 16:34 pg_hba.conf
-rw-r--r-- 1 barman barman 27012 Sep 17 17:54 postgresql.conf
drwx------ 2 barman barman  4096 Sep 17 17:54 pg_notify
drwx------ 2 barman barman  4096 Sep 17 17:54 pg_stat
drwx------ 4 barman barman  4096 Sep 17 17:55 pg_logical
drwx------ 2 barman barman  4096 Sep 17 17:55 pg_wal
drwx------ 2 barman barman  4096 Sep 17 17:55 global
-rw-rw-r-- 1 barman barman   249 Sep 17 17:55 backup_label
drwx------ 2 barman barman  4096 Sep 17 18:10 pg_tblspc

Here base directory in barman server.

I read in one of the blog that pg_basebackup will skip all the datafiles


Notes

At the beginning of the backup, a checkpoint needs to be written on the server the backup is taken from. Especially if the option --checkpoint=fast is not used, this can take some time during which pg_basebackup will be appear to be idle.

The backup will include all files in the data directory and tablespaces, including the configuration files and any additional files placed in the directory by third parties, except certain temporary files managed by PostgreSQL. But only regular files and directories are copied, except that symbolic links used for tablespaces are preserved. Symbolic links pointing to certain directories known to PostgreSQL are copied as empty directories. Other symbolic links and special device files are skipped. See Section 52.4 for the precise details.



Also I noticed that when I am triggering backups using barman it is taking only WAL files and directory structure and plan files.

Regards,
Kiran

Muhammad Amer Siddique

unread,
Sep 17, 2020, 8:51:28 AM9/17/20
to pgba...@googlegroups.com
Contents from server where you are trying to restore?



Kiran Kumar Jadaprolu

unread,
Sep 17, 2020, 9:07:35 AM9/17/20
to Barman, Backup and Recovery Manager for PostgreSQL
Hi Amer,

I have deleted all the backup files and triggered fresh DB backup. See the out put as below. Also I am providing target server data contents.

barman@barman-Server:~/PostgreSQL-Primary$ barman check PostgreSQL-Primary
Server PostgreSQL-Primary:
        PostgreSQL: OK
        superuser or standard user with backup privileges: 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: OK (have 0 backups, expected at least 0)
        ssh: OK (PostgreSQL server)
        systemid coherence: OK
        archive_mode: OK
        archive_command: OK
        continuous archiving: OK
        archiver errors: OK
barman@barman-Server:~/PostgreSQL-Primary$ barman backup PostgreSQL-Primary
Starting backup using rsync-concurrent method for server PostgreSQL-Primary in /var/lib/barman/PostgreSQL-Primary/base/20200917T183313
Backup start at LSN: 7/44000028 (000000010000000700000044, 00000028)
This is the first backup for server PostgreSQL-Primary
WAL segments preceding the current backup have been found:
        000000010000000700000042 from server PostgreSQL-Primary has been removed
Starting backup copy via rsync/SSH for 20200917T183313
Copy done (time: 4 seconds)
This is the first backup for server PostgreSQL-Primary
Asking PostgreSQL server to finalize the backup.
Backup size: 730.3 KiB
Backup end at LSN: 7/44000100 (000000010000000700000044, 00000100)
Backup completed (start time: 2020-09-17 18:33:13.469582, elapsed time: 9 seconds)
Processing xlog segments from file archival for PostgreSQL-Primary
        000000010000000700000043
        000000010000000700000044
        000000010000000700000044.00000028.backup
barman@barman-Server:~/PostgreSQL-Primary$ barman list-backup PostgreSQL-Primary
PostgreSQL-Primary 20200917T183313 - Thu Sep 17 18:33:20 2020 - Size: 746.3 KiB - WAL Size: 0 B (tablespaces: samplets:/var/lib/postgresql/12/main/base)
barman@barman-Server:~/PostgreSQL-Primary$ barman recover --remote-ssh-command "ssh postgres@PostgreSQL-Secondary"   PostgreSQL-Primary 20200917T183313 /var/lib/postgresql/12/main
Starting remote restore for server PostgreSQL-Primary using backup 20200917T183313
Destination directory: /var/lib/postgresql/12/main
Remote command: ssh postgres@PostgreSQL-Secondary
Using safe horizon time for smart rsync copy: 2020-09-17 15:19:58.707074+05:30
        16386, samplets, /var/lib/postgresql/12/main/base
Copying the base backup.
Copying required WAL segments.
Generating archive status files
Identify dangerous settings in destination directory.

IMPORTANT
These settings have been modified to prevent data losses

postgresql.conf line 233: archive_command = false

WARNING
You are required to review the following options as potentially dangerous

postgresql.conf line 40: data_directory = '/var/lib/postgresql/12/main'         # use data in another directory
postgresql.conf line 42: hba_file = '/etc/postgresql/12/main/pg_hba.conf'       # host-based authentication file
postgresql.conf line 44: ident_file = '/etc/postgresql/12/main/pg_ident.conf'   # ident configuration file
postgresql.conf line 48: external_pid_file = '/var/run/postgresql/12-main.pid'                  # write an extra PID file
postgresql.conf line 65: unix_socket_directories = '/var/run/postgresql'        # comma-separated list of directories
postgresql.conf line 101: ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem'
postgresql.conf line 103: ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key'
postgresql.conf line 740: include_dir = 'conf.d'                        # include files ending in '.conf' from

Recovery completed (start time: 2020-09-17 18:34:16.890503, elapsed time: 21 seconds)

Your PostgreSQL server has been successfully prepared for recovery!


Target Server:

postgres@PostgreSQL-Secondary:~/12/main$ ls -ltr
total 152
-rwx------ 1 postgres postgres     3 Jul 20 16:48 PG_VERSION
drwx------ 2 postgres postgres  4096 Jul 20 16:48 pg_twophase
drwx------ 2 postgres postgres  4096 Jul 20 16:48 pg_stat_tmp
drwx------ 2 postgres postgres  4096 Jul 20 16:48 pg_snapshots
drwx------ 2 postgres postgres  4096 Jul 20 16:48 pg_serial
drwx------ 4 postgres postgres  4096 Jul 20 16:48 pg_multixact
drwx------ 2 postgres postgres  4096 Jul 20 16:48 pg_dynshmem
drwx------ 2 postgres postgres  4096 Jul 20 16:48 pg_commit_ts
-rwx------ 1 postgres postgres    88 Jul 20 16:48 postgresql.auto.conf.origin
drwx------ 2 postgres postgres  4096 Jul 20 16:48 pg_xact
-rw-r----- 1 postgres postgres  1636 Jul 20 16:48 pg_ident.conf
drwx------ 2 postgres postgres  4096 Aug  4 21:26 pg_tblspc
drwx------ 2 postgres postgres  4096 Sep  2 21:57 pg_subtrans
drwx------ 3 postgres postgres  4096 Sep 10 10:47 base
-rw-r----- 1 postgres postgres  4976 Sep 17 16:34 pg_hba.conf
drwx------ 2 postgres postgres  4096 Sep 17 18:07 pg_replslot
-rw-r--r-- 1 postgres postgres 26930 Sep 17 18:28 postgresql.conf.origin
drwx------ 2 postgres postgres  4096 Sep 17 18:28 pg_notify
drwx------ 2 postgres postgres  4096 Sep 17 18:28 pg_stat
drwx------ 4 postgres postgres  4096 Sep 17 18:33 pg_logical
drwx------ 2 postgres postgres  4096 Sep 17 18:33 global
-rw-rw-r-- 1 postgres postgres   249 Sep 17 18:33 backup_label
drwx------ 3 postgres postgres  4096 Sep 17 18:34 pg_wal
-rw-r--r-- 1 postgres postgres 26962 Sep 17 18:34 postgresql.conf
-rwx------ 1 postgres postgres    88 Sep 17 18:34 postgresql.auto.conf

** Base folder is empty even after successful restoration.

Regards,
Kiran

Muhammad Amer Siddique

unread,
Sep 17, 2020, 10:05:33 AM9/17/20
to pgba...@googlegroups.com
IF you start server on seconder mechine what is error? 

Kiran Kumar Jadaprolu

unread,
Sep 17, 2020, 10:15:17 AM9/17/20
to Barman, Backup and Recovery Manager for PostgreSQL
root@PostgreSQL-Secondary:/var/log/postgresql# tail -30f postgresql-12-main.log
2020-09-17 19:44:27.182 IST [14205] LOG:  starting PostgreSQL 12.4 (Ubuntu 12.4-1.pgdg18.04+1) on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0, 64-bit
2020-09-17 19:44:27.182 IST [14205] LOG:  listening on IPv4 address "192.168.0.111", port 5432
2020-09-17 19:44:27.187 IST [14205] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2020-09-17 19:44:27.211 IST [14206] LOG:  database system was interrupted; last known up at 2020-09-17 18:33:13 IST
2020-09-17 19:44:27.304 IST [14206] LOG:  redo starts at 7/44000028
2020-09-17 19:44:27.307 IST [14206] LOG:  consistent recovery state reached at 7/44000100
2020-09-17 19:44:27.307 IST [14206] LOG:  redo done at 7/4D000110
2020-09-17 19:44:27.661 IST [14205] LOG:  database system is ready to accept connections
2020-09-17 19:44:28.809 IST [14216] postgres@postgres FATAL:  database "postgres" does not exist
2020-09-17 19:44:28.809 IST [14216] postgres@postgres DETAIL:  The database subdirectory "base/13442" is missing.
2020-09-17 19:44:29.348 IST [14219] postgres@postgres FATAL:  database "postgres" does not exist
2020-09-17 19:44:29.348 IST [14219] postgres@postgres DETAIL:  The database subdirectory "base/13442" is missing.
2020-09-17 19:44:29.889 IST [14222] postgres@postgres FATAL:  database "postgres" does not exist
2020-09-17 19:44:29.889 IST [14222] postgres@postgres DETAIL:  The database subdirectory "base/13442" is missing.
2020-09-17 19:44:30.428 IST [14225] postgres@postgres FATAL:  database "postgres" does not exist
2020-09-17 19:44:30.428 IST [14225] postgres@postgres DETAIL:  The database subdirectory "base/13442" is missing.
2020-09-17 19:44:30.968 IST [14228] postgres@postgres FATAL:  database "postgres" does not exist
2020-09-17 19:44:30.968 IST [14228] postgres@postgres DETAIL:  The database subdirectory "base/13442" is missing.
2020-09-17 19:44:31.508 IST [14231] postgres@postgres FATAL:  database "postgres" does not exist
2020-09-17 19:44:31.508 IST [14231] postgres@postgres DETAIL:  The database subdirectory "base/13442" is missing.
2020-09-17 19:44:32.048 IST [14234] postgres@postgres FATAL:  database "postgres" does not exist
2020-09-17 19:44:32.048 IST [14234] postgres@postgres DETAIL:  The database subdirectory "base/13442" is missing.
2020-09-17 19:44:32.587 IST [14237] postgres@postgres FATAL:  database "postgres" does not exist
2020-09-17 19:44:32.587 IST [14237] postgres@postgres DETAIL:  The database subdirectory "base/13442" is missing.
2020-09-17 19:44:33.127 IST [14240] postgres@postgres FATAL:  database "postgres" does not exist
2020-09-17 19:44:33.127 IST [14240] postgres@postgres DETAIL:  The database subdirectory "base/13442" is missing.
2020-09-17 19:44:33.668 IST [14243] postgres@postgres FATAL:  database "postgres" does not exist
2020-09-17 19:44:33.668 IST [14243] postgres@postgres DETAIL:  The database subdirectory "base/13442" is missing.
2020-09-17 19:44:34.209 IST [14246] postgres@postgres FATAL:  database "postgres" does not exist
2020-09-17 19:44:34.209 IST [14246] postgres@postgres DETAIL:  The database subdirectory "base/13442" is missing.

Muhammad Amer Siddique

unread,
Sep 17, 2020, 10:23:53 AM9/17/20
to pgba...@googlegroups.com
 Could you please regenerate backup with Rsync method. 


Restore on different location. Just to be more specific, pgbasebackup ways do backup. 


Regards, Amer

Kiran Kumar Jadaprolu

unread,
Sep 17, 2020, 10:53:06 AM9/17/20
to Barman, Backup and Recovery Manager for PostgreSQL
Hi Amer,

Before triggering the backup. Please review my config files. If all looks good let me know I will trigger backup again.

barman@barman-Server:/etc/barman.d$ cat PostgreSQL-Primary.conf
[PostgreSQL-Primary]
description = "Main DB Server"
ssh_command = ssh post...@192.168.0.108
conninfo = host=PostgreSQL-Primary user=barman dbname=postgres port=5432 password=xxxxxxxx
backup_method = rsync
archiver = on

barman@barman-Server:/etc$ cat barman.conf
; Barman, Backup and Recovery Manager for PostgreSQL
;
; Main configuration file

[barman]
; Main directory
barman_home = /var/lib/barman

; Locks directory - default: %(barman_home)s
;barman_lock_directory = /var/run/barman

; System user
barman_user = barman

; Log location
log_file = /var/log/barman/barman.log

; Default compression level: possible values are None (default), bzip2, gzip or custom
compression = gzip

; Incremental backup support: possible values are None (default), link or copy
;reuse_backup = off

; Pre/post backup hook scripts
;pre_backup_script = env | grep ^BARMAN
;pre_backup_retry_script = env | grep ^BARMAN
;post_backup_retry_script = env | grep ^BARMAN
;post_backup_script = env | grep ^BARMAN

; Pre/post archive hook scripts
;pre_archive_script = env | grep ^BARMAN
;pre_archive_retry_script = env | grep ^BARMAN
;post_archive_retry_script = env | grep ^BARMAN
;post_archive_script = env | grep ^BARMAN

; Directory of configuration files. Place your sections in separate files with .conf extension
; For example place the 'main' server section in /etc/barman.d/main.conf
configuration_files_directory = /etc/barman.d

; Minimum number of required backups (redundancy) - default 0
;minimum_redundancy = 1

; Global retention policy (REDUNDANCY or RECOVERY WINDOW) - default empty
;retention_policy =

; Global bandwidth limit in KBPS - default 0 (meaning no limit)
;bandwidth_limit = 4000

; Immediate checkpoint for backup command - default false
immediate_checkpoint = true

; Enable network compression for data transfers - default false
;network_compression = false

; Identify the standard behavior for backup operations: possible values are
; exclusive_backup (default), concurrent_backup
backup_options = concurrent_backup

; Number of retries of data copy during base backup after an error - default 0
basebackup_retry_times = 3

; Number of seconds of wait after a failed copy, before retrying - default 30
basebackup_retry_sleep = 30

; Time frame that must contain the latest backup date.
; If the latest backup is older than the time frame, barman check
; command will report an error to the user.
; If empty, the latest backup is always considered valid.
; Syntax for this option is: "i (DAYS | WEEKS | MONTHS)" where i is an
; integer > 0 which identifies the number of days | weeks | months of
; validity of the latest backup for this check. Also known as 'smelly backup'.
; last_backup_maximum_age = 1 DAYS

;; ; 'main' PostgreSQL Server configuration
;; [main]
;; ; Human readable description
;; description =  "Main PostgreSQL Database"
;;
;; ; SSH options
;; ssh_command = ssh postgres@pg
;;
;; ; PostgreSQL connection string
;; conninfo = host=pg user=postgres
;;
;; ; Minimum number of required backups (redundancy)
;; ; minimum_redundancy = 1
;;
;; ; Examples of retention policies
;;
;; ; Retention policy (disabled)
;; ; retention_policy =
;; ; Retention policy (based on redundancy)
;; ; retention_policy = REDUNDANCY 2
;; ; Retention policy (based on recovery window)
;; ;retention_policy = RECOVERY WINDOW OF 1 DAYS

============

Backup command :

barman backup PostgreSQL-Primary

Regards,
Kiran

Message has been deleted

Muhammad Amer Siddique

unread,
Sep 17, 2020, 11:09:40 AM9/17/20
to pgba...@googlegroups.com
Please do the following ... I think you don't have configured ssh key auth ...

barman check servname 
barman backup servername
Barman list backup
barman showbackup 
barman list-files options Server_name backup_id

Recover ..
barman recover --remote-ssh-command "ssh postgres@PostgreSQL-Secondary"   PostgreSQL-Primary 20200917T151958 /var/lib/postgresql/12/main_data

Are you sure no automation script is running on this machine ?

Regards, Amer


Kiran Kumar Jadaprolu

unread,
Sep 17, 2020, 11:24:26 AM9/17/20
to Barman, Backup and Recovery Manager for PostgreSQL
barman@barman-Server:/etc$ barman check PostgreSQL-Primary
Server PostgreSQL-Primary:
        PostgreSQL: OK
        superuser or standard user with backup privileges: 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: OK (have 2 backups, expected at least 0)
        ssh: OK (PostgreSQL server)
        systemid coherence: OK
        archive_mode: OK
        archive_command: OK
        continuous archiving: OK
        archiver errors: OK


barman@barman-Server:/etc$ barman backup PostgreSQL-Primary
Starting backup using rsync-concurrent method for server PostgreSQL-Primary in /var/lib/barman/PostgreSQL-Primary/base/20200917T204522
Backup start at LSN: 7/4F000028 (00000001000000070000004F, 00000028)
Starting backup copy via rsync/SSH for 20200917T204522
Copy done (time: 4 seconds)
Asking PostgreSQL server to finalize the backup.
Backup size: 730.3 KiB
Backup end at LSN: 7/4F000100 (00000001000000070000004F, 00000100)
Backup completed (start time: 2020-09-17 20:45:22.455829, elapsed time: 9 seconds)
Processing xlog segments from file archival for PostgreSQL-Primary
        00000001000000070000004E
        00000001000000070000004F
        00000001000000070000004F.00000028.backup


barman@barman-Server:/etc$ barman list-backup PostgreSQL-Primary
PostgreSQL-Primary 20200917T204522 - Thu Sep 17 20:45:28 2020 - Size: 746.4 KiB - WAL Size: 0 B (tablespaces: samplets:/var/lib/postgresql/12/main/base)
PostgreSQL-Primary 20200917T193105 - Thu Sep 17 19:31:12 2020 - Size: 746.3 KiB - WAL Size: 96.5 KiB (tablespaces: samplets:/var/lib/postgresql/12/main/base)
PostgreSQL-Primary 20200917T183313 - Thu Sep 17 18:33:20 2020 - Size: 746.3 KiB - WAL Size: 80.5 KiB (tablespaces: samplets:/var/lib/postgresql/12/main/base)

barman@barman-Server:/etc$ barman show-backup PostgreSQL-Primary 20200917T204522
Backup 20200917T204522:
  Server Name            : PostgreSQL-Primary
  System Id              : 6851520378512605282
  Status                 : DONE
  PostgreSQL Version     : 120003
  PGDATA directory       : /var/lib/postgresql/12/main
  Tablespaces:
    samplets: /var/lib/postgresql/12/main/base (oid: 16386)

  Base backup information:
    Disk usage           : 730.3 KiB (746.4 KiB with WALs)
    Incremental size     : 730.3 KiB (-0.00%)
    Timeline             : 1
    Begin WAL            : 00000001000000070000004F
    End WAL              : 00000001000000070000004F
    WAL number           : 1
    WAL compression ratio: 99.90%
    Begin time           : 2020-09-17 20:45:22.283253+05:30
    End time             : 2020-09-17 20:45:28.792556+05:30
    Copy time            : 4 seconds + 2 seconds startup
    Estimated throughput : 181.3 KiB/s
    Begin Offset         : 40
    End Offset           : 256
    Begin LSN           : 7/4F000028
    End LSN             : 7/4F000100

  WAL information:
    No of files          : 0
    Disk usage           : 0 B
    Last available       : 00000001000000070000004F

  Catalog information:
    Retention Policy     : not enforced
    Previous Backup      : 20200917T193105
    Next Backup          : - (this is the latest base backup)


barman@barman-Server:/etc$ barman list-files PostgreSQL-Primary 20200917T204522
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/backup.info
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/pg_ident.conf
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/backup_label
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/PG_VERSION
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/pg_hba.conf
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/postgresql.conf
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/postgresql.auto.conf
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/2672
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/4184
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/1260_fsm
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/2965
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/6115
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/2396_vm
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/2966
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/4186
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/1136_vm
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/3592
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/2967
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/4060
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/4183
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/6001
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/6000
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/1262_fsm
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/1136
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/2397
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/1213_vm
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/6114
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/pg_control
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/4176
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/1233
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/1213_fsm
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/2695
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/1260_vm
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/6100
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/4179
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/2671
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/2698
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/2847
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/1261_fsm
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/2396_fsm
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/2396
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/1137
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/1214_fsm
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/1136_fsm
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/4180
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/1262_vm
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/4185
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/1214
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/2846
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/4061
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/1214_vm
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/pg_filenode.map
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/3593
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/4178
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/4177
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/1262
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/4182
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/6002
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/2677
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/2697
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/4175
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/2676
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/1261
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/1261_vm
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/4181
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/1260
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/1213
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/2964
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/2694
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/global/1232
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/pg_xact/0000
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/pg_multixact/members/0000
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/pg_multixact/offsets/0000
/var/lib/barman/PostgreSQL-Primary/base/20200917T204522/data/pg_logical/replorigin_checkpoint
/var/lib/barman/PostgreSQL-Primary/wals/0000000100000007/00000001000000070000004F


As per my knowledge there are no automatic jobs scheduled on this server.

Tried restoration as well but no luck.

barman@barman-Server:/etc$  barman recover --remote-ssh-command "ssh postgres@PostgreSQL-Secondary"   PostgreSQL-Primary 20200917T183313 /var/lib/postgresql/12/main_data
Starting remote restore for server PostgreSQL-Primary using backup 20200917T183313
Destination directory: /var/lib/postgresql/12/main_data
Remote command: ssh postgres@PostgreSQL-Secondary
        16386, samplets, /var/lib/postgresql/12/main/base
Copying the base backup.
Copying required WAL segments.
Generating archive status files
Identify dangerous settings in destination directory.

IMPORTANT
These settings have been modified to prevent data losses

postgresql.conf line 233: archive_command = false

WARNING
You are required to review the following options as potentially dangerous

postgresql.conf line 40: data_directory = '/var/lib/postgresql/12/main'         # use data in another directory
postgresql.conf line 42: hba_file = '/etc/postgresql/12/main/pg_hba.conf'       # host-based authentication file
postgresql.conf line 44: ident_file = '/etc/postgresql/12/main/pg_ident.conf'   # ident configuration file
postgresql.conf line 48: external_pid_file = '/var/run/postgresql/12-main.pid'                  # write an extra PID file
postgresql.conf line 65: unix_socket_directories = '/var/run/postgresql'        # comma-separated list of directories
postgresql.conf line 101: ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem'
postgresql.conf line 103: ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key'
postgresql.conf line 740: include_dir = 'conf.d'                        # include files ending in '.conf' from

Recovery completed (start time: 2020-09-17 20:50:56.020150, elapsed time: 26 seconds)

Your PostgreSQL server has been successfully prepared for recovery!

In Target Server:

root@PostgreSQL-Secondary:/var/lib/postgresql/12/main_data# ls -ltr
total 148
-rwx------ 1 postgres postgres     3 Jul 20 16:48 PG_VERSION
drwx------ 2 postgres postgres  4096 Jul 20 16:48 pg_twophase
drwx------ 2 postgres postgres  4096 Jul 20 16:48 pg_stat_tmp
drwx------ 2 postgres postgres  4096 Jul 20 16:48 pg_snapshots
drwx------ 2 postgres postgres  4096 Jul 20 16:48 pg_serial
drwx------ 4 postgres postgres  4096 Jul 20 16:48 pg_multixact
drwx------ 2 postgres postgres  4096 Jul 20 16:48 pg_dynshmem
drwx------ 2 postgres postgres  4096 Jul 20 16:48 pg_commit_ts
-rwx------ 1 postgres postgres    88 Jul 20 16:48 postgresql.auto.conf.origin
drwx------ 2 postgres postgres  4096 Jul 20 16:48 pg_xact
-rw-r----- 1 postgres postgres  1636 Jul 20 16:48 pg_ident.conf
drwx------ 2 postgres postgres  4096 Aug  4 21:26 pg_tblspc
drwx------ 2 postgres postgres  4096 Sep  2 21:57 pg_subtrans
-rw-r----- 1 postgres postgres  4976 Sep 17 16:34 pg_hba.conf
drwx------ 2 postgres postgres  4096 Sep 17 18:07 pg_replslot
-rw-r--r-- 1 postgres postgres 26930 Sep 17 18:28 postgresql.conf.origin
drwx------ 2 postgres postgres  4096 Sep 17 18:28 pg_notify
drwx------ 2 postgres postgres  4096 Sep 17 18:28 pg_stat
drwx------ 4 postgres postgres  4096 Sep 17 18:33 pg_logical
drwx------ 2 postgres postgres  4096 Sep 17 18:33 global
-rw-rw-r-- 1 postgres postgres   249 Sep 17 18:33 backup_label
drwx------ 3 postgres postgres  4096 Sep 17 20:51 pg_wal
-rw-r--r-- 1 postgres postgres 26962 Sep 17 20:51 postgresql.conf
-rwx------ 1 postgres postgres    88 Sep 17 20:51 postgresql.auto.conf

Is there different command to trigger full database backup?
How to check whether the backup is full/incremental/wal backup?

Regards,
Kiran

Muhammad Amer Siddique

unread,
Sep 17, 2020, 11:39:26 AM9/17/20
to pgba...@googlegroups.com
Please recover PostgreSQL-Primary 20200917T204522 backup set.

Secondly, connect with you primary server and check status of database and check logfiles.

As you have tablespace created just check location and clear contents on standby before restoring.

Kiran Kumar Jadaprolu

unread,
Sep 17, 2020, 12:24:23 PM9/17/20
to Barman, Backup and Recovery Manager for PostgreSQL
barman@barman-Server:/etc$ barman recover --remote-ssh-command "ssh postgres@PostgreSQL-Secondary"   PostgreSQL-Primary 20200917T204522 /var/lib/postgresql/12/main_data
Starting remote restore for server PostgreSQL-Primary using backup 20200917T204522
Destination directory: /var/lib/postgresql/12/main_data
Remote command: ssh postgres@PostgreSQL-Secondary
Using safe horizon time for smart rsync copy: 2020-09-17 18:33:13.244667+05:30
        16386, samplets, /var/lib/postgresql/12/main/base
Copying the base backup.
Copying required WAL segments.
Generating archive status files
Identify dangerous settings in destination directory.

IMPORTANT
These settings have been modified to prevent data losses

postgresql.conf line 233: archive_command = false

WARNING
You are required to review the following options as potentially dangerous

postgresql.conf line 40: data_directory = '/var/lib/postgresql/12/main'         # use data in another directory
postgresql.conf line 42: hba_file = '/etc/postgresql/12/main/pg_hba.conf'       # host-based authentication file
postgresql.conf line 44: ident_file = '/etc/postgresql/12/main/pg_ident.conf'   # ident configuration file
postgresql.conf line 48: external_pid_file = '/var/run/postgresql/12-main.pid'                  # write an extra PID file
postgresql.conf line 65: unix_socket_directories = '/var/run/postgresql'        # comma-separated list of directories
postgresql.conf line 101: ssl_cert_file = '/etc/ssl/certs/ssl-cert-snakeoil.pem'
postgresql.conf line 103: ssl_key_file = '/etc/ssl/private/ssl-cert-snakeoil.key'
postgresql.conf line 740: include_dir = 'conf.d'                        # include files ending in '.conf' from

Recovery completed (start time: 2020-09-17 21:47:46.138358, elapsed time: 22 seconds)

Your PostgreSQL server has been successfully prepared for recovery!
root@PostgreSQL-Secondary:/var/lib/postgresql/12/main_data# ls -ltr
total 148
-rwx------ 1 postgres postgres     3 Jul 20 16:48 PG_VERSION
drwx------ 2 postgres postgres  4096 Jul 20 16:48 pg_twophase
drwx------ 2 postgres postgres  4096 Jul 20 16:48 pg_stat_tmp
drwx------ 2 postgres postgres  4096 Jul 20 16:48 pg_snapshots
drwx------ 2 postgres postgres  4096 Jul 20 16:48 pg_serial
drwx------ 4 postgres postgres  4096 Jul 20 16:48 pg_multixact
drwx------ 2 postgres postgres  4096 Jul 20 16:48 pg_dynshmem
drwx------ 2 postgres postgres  4096 Jul 20 16:48 pg_commit_ts
-rwx------ 1 postgres postgres    88 Jul 20 16:48 postgresql.auto.conf.origin
drwx------ 2 postgres postgres  4096 Jul 20 16:48 pg_xact
-rw-r----- 1 postgres postgres  1636 Jul 20 16:48 pg_ident.conf
drwx------ 2 postgres postgres  4096 Aug  4 21:26 pg_tblspc
drwx------ 2 postgres postgres  4096 Sep  2 21:57 pg_subtrans
-rw-r--r-- 1 postgres postgres 26930 Sep 17 18:28 postgresql.conf.origin
drwx------ 2 postgres postgres  4096 Sep 17 18:28 pg_notify
drwx------ 2 postgres postgres  4096 Sep 17 18:28 pg_stat
-rw-r----- 1 postgres postgres  5050 Sep 17 19:37 pg_hba.conf
drwx------ 2 postgres postgres  4096 Sep 17 19:41 pg_replslot
drwx------ 4 postgres postgres  4096 Sep 17 20:45 pg_logical
drwx------ 2 postgres postgres  4096 Sep 17 20:45 global
-rw-rw-r-- 1 postgres postgres   249 Sep 17 20:45 backup_label
drwx------ 3 postgres postgres  4096 Sep 17 21:42 pg_wal
-rw-r--r-- 1 postgres postgres 26962 Sep 17  2020 postgresql.conf
-rwx------ 1 postgres postgres    88 Sep 17  2020 postgresql.auto.conf
root@PostgreSQL-Secondary:/var/lib/postgresql/12/main_data#


** i don't see any issues with my Primary database. but in target I can't find "base" directory.

DDL of tablespace:

CREATE TABLESPACE samplets
  OWNER postgres
  LOCATION '/var/lib/postgresql/12/main/base';

ALTER TABLESPACE samplets
  OWNER TO postgres;

Kiran Kumar Jadaprolu

unread,
Sep 17, 2020, 12:32:39 PM9/17/20
to Barman, Backup and Recovery Manager for PostgreSQL
I have dropped samplets tablespace and triggered the backup. Worked fine.

Restoration also went fine.

May be I have created tablespace with wrong location (default). Let me try with different location and will try same :)

Thanks for your precious time, suggestions and help.

Regards,
Kiran

Muhammad Amer Siddique

unread,
Sep 17, 2020, 12:32:56 PM9/17/20
to pgba...@googlegroups.com
Base directory is PostgreSQL directory thus please use other folder name than PostgreSQL own directory structure. Secondly, base directory exist on different location. It seems to be your tablespace is overwriting contents of actual directory erase and recreate etc. Also check main folder if base directory exist. 

Muhammad Amer Siddique

unread,
Sep 17, 2020, 12:34:22 PM9/17/20
to pgba...@googlegroups.com
Please don't use PostgreSQL directory structure for tablespace. 




Kiran Kumar Jadaprolu

unread,
Sep 17, 2020, 12:41:15 PM9/17/20
to Barman, Backup and Recovery Manager for PostgreSQL
Thanks Amer. I never expected this and unknowingly create tablespace with same location.

Lesson learned.

Regards,
Kiran

Reply all
Reply to author
Forward
0 new messages