Last active
January 30, 2023 06:54
-
-
Save ppa-odoo/ed4e3b1ce7423dbfed98bbdb2a90b654 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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