This script will help you to create automated backup (compressed) and automated deletion for your PostgresQL partitioned tables.
NOTE: This only works if you configured pg_partman to create partiotions weekly.
postgres-clinet
openssh-client
rsync
Open psql-partitions-auto-backup.bash
and set these variables:
CONNECTION_STRING
: Your PostgresQL connection stringBACKUP_SERVER
: Server that you want to store your backups on. Should have SSH.BACKUP_DIR
: Directory in<BACKUP_SERVER>
which backups will be saved to.DATABASE_NAME
: Your PostgresQL database name.TABLE_NAME
: Name of the table that has partitioning.TABLES_TO_KEEP
: Number of tables to keep.
chmod +x psql-partitions-auto-backup.bash
./psql-partitions-auto-backup.bash
Also you can add it as a cron job.