[Bps-public-commit] postgresql_auto_backup_s3 branch update-for-hostedrt-backups updated. 4d50bd2a2c9355c6fd1dccc7f043b2169379d87c

BPS Git Server git at git.bestpractical.com
Tue Mar 15 23:40:07 UTC 2022


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "postgresql_auto_backup_s3".

The branch, update-for-hostedrt-backups has been updated
       via  4d50bd2a2c9355c6fd1dccc7f043b2169379d87c (commit)
      from  e729a3720b8ee34ae5c33f08190d1b653a19f431 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 4d50bd2a2c9355c6fd1dccc7f043b2169379d87c
Author: Blaine Motsinger <blaine at bestpractical.com>
Date:   Tue Mar 15 18:39:59 2022 -0500

    Update README.md with usage, config, and setup

diff --git a/README.md b/README.md
index b6c2182..4b758e8 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,107 @@
-postgresql_auto_backup_s3
-=========================
+# postgresql_auto_backup_s3
 
 Configurable backup scripts to automate postgresql backups and push to s3 via stdin, plus rotation logic.
 
-Contributors welcome!
+## SYNOPSIS
 
-Original code from https://wiki.postgresql.org/wiki/Automated_Backup_on_Linux.
+```
+Usage: pg_backup_rotated.sh [-c <config_file>] [-q] [-h]
 
-Will be adapted to work with s3cmd stdin pushing, therefore needs s3cmd >= s3cmd 1.5.0-alpha1 , also see http://s3tools.org/news
+Options:
+    -c, --config <config_file>    load a specified config file
+    -q, --quiet                   silence output
+    -h, --help                    display this help and exit
+```
+
+## DESCRIPTION
+
+`postgresql_auto_backup_s3` provides the following scripts to create postgresql backups:
+
+- `pg_backup.sh`
+
+This script will create postgresql backups to a local disk directory, without backup rotation.
+
+- `pg_backup_rotated.sh`
+
+This script will create postgresql backups to an s3 bucket, with weekly and monthly backup rotation.
+
+## CONFIGURATION
+
+Configuration is done through through the `pg_backup.config` file, and contains the following variables:
+
+- `BACKUP_USER`
+
+Optional system user to run backups as.  If the user the script is running as doesn't match this the script terminates.  Leave blank to skip check.
+
+- `HOSTNAME`
+
+Optional hostname to adhere to pg_hba policies.  Will default to `localhost` if none specified.
+
+- `USERNAME`
+
+Optional username to connect to database as.  Will default to `postgres` if none specified.
+
+- `BACKUP_DIR`
+
+If running `pg_backup.sh`, `BACKUP_DIR` specifies the directory to write backups to, and will be created if it doesn't exist.  This must be writable by the user the script is running as.
+
+If running `pg_backup_rotated.sh`, `BACKUP_DIR` specifies the s3 bucket to write backups to.
+
+- `BACKUP_DB_LIST`
+
+List of database names to backup, separated by space or comma.
+
+- `DAY_OF_WEEK_TO_KEEP`
+
+Which day to take the weekly backup from (1-7 = Monday-Sunday).
+
+- `DAYS_TO_KEEP`
+
+Number of days to keep daily backups.
+
+- `WEEKS_TO_KEEP`
+
+How many weeks to keep weekly backups.
+
+## DEPENDENCIES
+
+`pg_backup_rotated.sh` requires the external program, `aws-cli` to upload backups to s3.  Please see the [aws-cli installation and setup instructions](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html) for more detail.
+
+## EXAMPLES
+
+### create local backups for two databases using a specified config file
+
+```
+$ cp -a pg_backup.config pg_backup.config.local
+$ vi cp -a pg_backup.config.local
+BACKUP_DIR=/home/bps/backups/database/postgresql/
+BACKUP_DB_LIST="rt4 rt5"
+
+$ bash pg_backup.sh --config pg_backup.config.local
+creating backup directory - /home/bps/backups/database/postgresql/2022-03-15/
+creating backup - /home/bps/backups/database/postgresql/2022-03-15/rt4.sql.gz
+creating backup - /home/bps/backups/database/postgresql/2022-03-15/rt5.sql.gz
+```
+
+### create backups and upload to s3 for two databases using a specified config file
+
+```
+$ cp -a pg_backup.config pg_backup.config.s3
+$ vi cp -a pg_backup.config.s3
+BACKUP_DIR=s3://s3backup-test-backup/pg_backups/
+BACKUP_DB_LIST="rt4 rt5"
+
+$ bash pg_backup.sh --config pg_backup.config.s3
+creating daily backup - s3://s3backup-test-backup/pg_backups/20220315-daily-rt4.sql.gz
+creating daily backup - s3://s3backup-test-backup/pg_backups/20220315-daily-rt5.sql.gz
+```
+
+## CAVEATS
+
+The backup scripts in `postgresql_auto_backup_s3` have been specifically modified to backup RT databases as outlined in the [RT 5.0.2 database administration documentation](https://docs.bestpractical.com/rt/5.0.2/system_administration/database.html#PostgreSQL).
+
+Backing up non-RT databases will warn about not finding the `sessions` table.
+
+```
+pg_dump: no matching tables were found
+```
-----------------------------------------------------------------------

Summary of changes:
 README.md | 107 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 102 insertions(+), 5 deletions(-)


hooks/post-receive
-- 
postgresql_auto_backup_s3


More information about the Bps-public-commit mailing list