Skip to content

Instantly share code, notes, and snippets.

@ppa-odoo
Last active January 30, 2023 06:54
Show Gist options
  • Save ppa-odoo/ed4e3b1ce7423dbfed98bbdb2a90b654 to your computer and use it in GitHub Desktop.
Save ppa-odoo/ed4e3b1ce7423dbfed98bbdb2a90b654 to your computer and use it in GitHub Desktop.
#!/bin/bash
# backup Location
dir="/home/dell/"
# Name of the backup files
date=`date +%d-%m-%Y`
databases=`psql -l -t | cut -d'|' -f1 | sed -e 's/ //g' -e '/^$/d'`
for i in $databases; do if [ "$i" != "postgres" ] && [ "$i" != "template0" ] && [ "$i" != "template1" ] && [ "$i" != "template_postgis" ]; then
echo Backup $i to $dir$i\_$date.sql
pg_dump $i > $dir$i\_$date.sql
fi
done
# given the permission
# chmod +x backup_pg_dump.sh
# run : ./backup_pg_dump.sh
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment