Skip to content

Instantly share code, notes, and snippets.

View 0x9n0p's full-sized avatar
🏠
Working from home

Mohammad 0x9n0p

🏠
Working from home
  • eSITE Information Technology LLC
  • 9.807 m/s²
View GitHub Profile
@0x9n0p
0x9n0p / backup.sh
Last active June 4, 2025 09:59
A simple bash script to back up PostgreSQL databases into separate files
#!/bin/bash
USER=postgres
BACKUP_DIR="/var/lib/pgsql/backup"
DAYS_TO_KEEP=29
BACKUP_FILE_SUFFIX=$(date +"%Y%m%d%H%M")
databases=$(psql -l -t | cut -d'|' -f1 | sed -e 's/ //g' -e '/^$/d')
for i in $databases; do