Simple system which use pg_dump for dump postgresql db and send info in to Telegram via Horn
-
Clone project
git clone https://github.com/Rishats/postgresql-backup.git
-
Change folder
cd postgresql-backup
-
Create .env file from .env.example
cp .env.example .env
-
Configure your .env
APP_ENV=production-or-other POSTGRESQL_HOST=127.0.0.1(or-empty-if-localhost) POSTGRESQL_PORT=3306 POSTGRESQL_DB=mydb POSTGRESQL_USER=mydbuser BACKUP_DIR=/var/lib/postgresql/backups/ INTEGRAM_WEBHOOK_URI=your-uri SENTRY_DSN=your-dsn ROTATED_TIME_DAILY=7 ROTATED_TIME_WEEKLY=4(or-empty-if-no-need) ROTATED_TIME_MONTHLY=12(or-empty-if-no-need)
Download dependency
go mod download
Build for linux
env GOOS=linux GOARCH=amd64 go build main.go
docker build --target=build-env -t postgresql-backup .
docker run -d --name "postgresql-backup" postgresql-backup
https://github.com/Rishats/ansible-postgresql-backup
-
Create scripts folder and download latest release with custom .env
mkdir scripts cp .env.example .env vim .env
-
Added example crontab entry
crontab -u postgres -e
0 2 * * * /var/lib/postgresql/scripts/postgresql-backup > /dev/null 2>&1
We use SemVer for versioning. For the versions available, see the tags on this repository.
- Rishat Sultanov - Rishats
This project is licensed under the MIT License - see the LICENSE.md file for details