https://github.com/moeen/psql-partitions-auto-backup
Backup and drop partitioned tables in PostgresQL
https://github.com/moeen/psql-partitions-auto-backup
backup partman postgres postgresql
Last synced: about 2 months ago
JSON representation
Backup and drop partitioned tables in PostgresQL
- Host: GitHub
- URL: https://github.com/moeen/psql-partitions-auto-backup
- Owner: moeen
- License: mit
- Created: 2022-02-20T11:18:33.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-20T11:44:57.000Z (over 4 years ago)
- Last Synced: 2025-01-10T15:15:03.265Z (over 1 year ago)
- Topics: backup, partman, postgres, postgresql
- Language: Shell
- Homepage:
- Size: 4.88 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PostgresQL partiotioned tables automated backup and drop
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.
## Steps
### Install these packages
1. `postgres-clinet`
2. `openssh-client`
2. `rsync`
### Configure the script
Open `psql-partitions-auto-backup.bash` and set these variables:
- `CONNECTION_STRING`: Your PostgresQL connection string
- `BACKUP_SERVER`: Server that you want to store your backups on. Should have SSH.
- `BACKUP_DIR`: Directory in `` 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.
### Run the script
```sh
chmod +x psql-partitions-auto-backup.bash
./psql-partitions-auto-backup.bash
```
Also you can add it as a cron job.