Posts

Showing posts with the label Postgres

EDB - pgBackRest - Part III: RESTORE

  Theory The restore command automatically defaults to selecting the latest backup from the first repository where backups exist. The order in which the repositories are checked is dictated by the pgbackrest.conf (e.g. repo1 will be checked before repo2). To select from a specific repository, the --repo option can be passed (e.g. --repo=1). The --set option can be passed if a backup other than the latest is desired. Restoration Scenarios: Restoring the backup on a different host Restoring a single database from the Postgres cluster Restoring the backup to a specific point in time Restoring only the delta changes Restoring the backup on a different host to start as a streaming standby 1. Verify backup information [enterprisedb@edb-nhatrang ~]$ pgbackrest info --stanza=employees 2. Restoring the backup on a different host (IP : 192.168.56.77) Setup Passwordless SSH Connection between Backup Server (192.168.56.79) and Database Server (192.168.56.77) Backup Server  ss...

EDB - pgBackRest - Part II: Configuration & Backup

Theory A stanza is the configuration for a PostgreSQL database cluster that defines where it is located, how it will be backed up, archiving options, etc. Most db servers will only have one PostgreSQL database cluster and therefore one stanza, whereas backup servers will have a stanza for every database cluster that needs to be backed up. The stanza-delete command removes data in the repository associated with a stanza. Use this command with caution — it will permanently remove all backups and archives from the pgBackRest repository for the specified stanza. A. CONFIGURATION 1. Create backup location [root@edb-nhatrang /]# mkdir -p /backup/pgbackrest [root@edb-nhatrang /]# chown -R enterprisedb: /backup/ 2. Database Cluster Configuration Enable archive mode ON Set archive_command = ‘pgbackrest --stanza=employees archive-push %p’ Get data_directory = ‘/u01/edb/as16/data’ edb=# show archive_mode ;  archive_mode  --------------  on (1 row) edb=# show archive_command ...

EDB - pgBackRest - Part I: Installation

In this section, we will install pgBackRest using with  EPAS  (EDB Enterprise Advance Server). So we need to pay attention to something such as: User is enterprisedb , not postgres Grant right privileges to enterprisedb user 1. Configuring Postgres YUM repository [root@edb-nhatrang ~]# dnf repolist  [root@edb-nhatrang ~]# dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm [root@edb-nhatrang ~]# dnf repolist  2. Configuring EPEL Repository [root@edb-nhatrang ~]# dnf install https://dl.fedoraproject.org/pub/epel/epel-release-latest-9.noarch.rpm [root@edb-nhatrang ~]# dnf repolist  3. Install pgBackRest [root@edb-nhatrang ~]# dnf install pgbackrest Using EDB Postgres Advanced Server, the enterprisedb system user will execute the pgbackrest command. The following commands will change the ownership of the pgBackRest directories: [root@edb-nhatrang ~]# chown -R enterprisedb: /var/lib/pgbackrest [root@ed...

EDB - Barman - Part IV: Remote Recovery Database

  Note : The  recover  command is used to recover a whole server. Remote recovery -  Add the --remote-ssh-command  option to the invocation of the recovery command.  Doing this will allow Barman to execute the copy on a remote server, using the provided command to connect to the remote host.  The SSH connection between Barman and the remote host  must   use the public key exchange authentication method. Barman wraps PostgreSQL's Point-in-Time Recovery (PITR), allowing you to specify a recovery target, either as a timestamp , as a restore label , or as a transaction ID . Barman 2.4 also adds the --standby-mode option for the recover command which, if specified, properly configures the recovered instance as a standby by creating a standby.signal file (from PostgreSQL versions lower than 12), or by adding standby_mode = on to the generated recovery configuration. Barman allows you to specify a target timeline for recovery using the --target-t...

EDB - Barman - Part III: Backup via Streaming protocol

In  Part I , we have already configured backup via Streaming protocol. In this section, we will backup database with this method. Note : The reuse_backup option can’t be used with the postgres backup method at this time If a backup has been compressed using the backup_compression option then barman recover is able to uncompress the backup on recovery. Using the recovery_staging_path option in order to choose a suitable location for the staging directory to unpcompress. S et recovery_staging_path in the global/server config or use the --recovery-staging-path option with the barman recover command 1. Check information On Database server edb=# select * from pg_replication_slots; -[ RECORD 1 ]-------+----------- slot_name            | barman plugin               | slot_type            | physical datoid ...