dnf install -y postgresql10 postgresql10-server pgmoneta
export PATH=/usr/pgsql-10/bin:$PATH initdb /tmp/pgsql
as postgres user
host all all 127.0.0.1/32 trust host all all ::1/128 trust host replication all 127.0.0.1/32 trust host replication all ::1/128 trustfrom /tmp/pgsql/pg_hba.conf.
as postgres user
host mydb myuser 127.0.0.1/32 md5 host mydb myuser ::1/128 md5 host postgres repl 127.0.0.1/32 md5 host postgres repl ::1/128 md5 host replication repl 127.0.0.1/32 md5 host replication repl ::1/128 md5to /tmp/pgsql/pg_hba.conf. Or use scram-sha-256.
Remember to check the value of password_encryption in /tmp/pgsql/postgresql.conf to setup the correct authentication type.
as postgres user
wal_level = replicais set in /tmp/pgsql/postgresql.conf - or logical
as postgres user
pg_ctl -D /tmp/pgsql/ startas postgres user
createuser -P myuser createdb -E UTF8 -O myuser mydbwith mypass as the password.
Then
psql postgres CREATE ROLE repl WITH LOGIN REPLICATION PASSWORD 'secretpassword'; \qas postgres user
psql -h localhost -p 5432 -U myuser mydb \qFor the user (pgmoneta) (using secretpassword)
psql -h localhost -p 5432 -U repl postgres \qas postgres user
sudo su - useradd -ms /bin/bash pgmoneta passwd pgmoneta exitas postgres user
sudo su - su - pgmonetaAdd the master key and create vault
pgmoneta-admin master-key pgmoneta-admin -f pgmoneta_users.conf -U repl -P secretpassword add-userYou have to choose a password for the master key - remember it !
Create the pgmoneta.conf configuration
cat > pgmoneta.conf [pgmoneta] host = * metrics = 5001 base_dir = /home/pgmoneta/backup compression = zstd storage_engine = local retention = 7 log_type = file log_level = info log_path = /tmp/pgmoneta.log unix_socket_dir = /tmp/ pgsql_dir = /usr/pgsql-10/bin/ [primary] host = localhost port = 5432 user = repland press Ctrl-D
as postgres user
mkdir backupas pgmoneta user
pgmoneta -c pgmoneta.conf -u pgmoneta_users.confas pgmoneta user
pgmoneta-cli -c pgmoneta.conf backup primaryas pgmoneta user
pgmoneta-cli -c pgmoneta.conf detailsas pgmoneta user
It is required to source the script into your current shell, for instance by doing:
source contrib/shell_comp/pgmoneta_comp.bashAt this point, the completions should be active, so you can type the name of one the commands between pgmoneta-cli and pgmoneta-admin and hit TAB to help the command line completion.
autoload -U compinit compinitand add the sourcing of the contrib/shell_comp/pgmoneta_comp.zsh file into your ~/.zshrc also associating the _pgmoneta_cli and _pgmoneta_admin functions to completion by means of compdef:
source contrib/shell_comp/pgmoneta_comp.zsh compdef _pgmoneta_cli pgmoneta-cli compdef _pgmoneta_admin pgmoneta-adminIf you want completions only for one command, e.g., pgmoneta-admin, remove the compdef line that references the command you don't want to have automatic completion. At this point, digit the name of a pgmoneta-cli or pgmoneta-admin command and hit TAB to trigger the completion system.