Skip to content

Instantly share code, notes, and snippets.

View jirevwe's full-sized avatar
🏠
Working from home

Raymond Tukpe jirevwe

🏠
Working from home
View GitHub Profile
@jirevwe
jirevwe / pg_dump.sh
Last active December 19, 2024 19:41
Backup all databases in pg instance
#!/bin/bash
# Usage
# 1. perform backup: bash backup.sh -c "postgres://user:password@hostname:5432/dbname?sslmode=require"
# 2. unzip: gunzip -c dump/full_backup_20241101_081322.sql.gz > restore.sql
# 3. restore: psql -h hostname -p 5432 -U dedicateddbadmin -d postgres -f restore.sql
# 4. unzip and restore: gunzip -c dump/full_backup_20241101_081322.sql.gz | psql -h hostname -p 5432 -U username -d postgres
# Help function
show_help() {