I am developing a Script in the Bash , for the automation of the creation of the Backups for the Postgresql engine. strong> in Centos , but I need to be able to ignore the databases that you define in a variable. and save the Dump in the root folder.
Here I show you an example of my Script, which generates me the Dump but I do not know how to ignore some databases and how to tell him to do all the ones I want.
Thank you very much, your help would be great
#!/bin/bash
usuario="postgres"
password="123"
db="test1"
puerto=5432
host="localhost"
DATE='date +%Y-%m-%d'
/usr/bin/pg_dump --host $host --port $puerto --username $usuario --no-password --format custom --blobs --verbose --file "/home/josealonso/Escritorio/backup2/B$db[$DATE].sql" "$db"
psql-l
I will join the code that I have managed to improve, during the course of the day:
#!/bin/bash
usuario='postgres'
password='123456a'
db=("test1" "test2")
puerto=5432
host='localhost'
ignore=("test3")
for item in ${db[*]}
do
if [[ $item != $ignore ]];
then
DATE='date +%Y-%m-%d
basedato=$item
/usr/bin/pg_dump --host $host --port $puerto --username $usuario --no-password --format custom --blobs --verbose --file "/home/josealonso/Escritorio/backup2/B$item[$DATE].sql" "$basedato"
echo 'El Backup De La Base de Datos' $basedato 'Fue Realizado con exito!!!'
sh script.sh
fi
done