Yedidyah Bar David has uploaded a new change for review. Change subject: packaging: engine-backup.sh fix info on failed restore ......................................................................
packaging: engine-backup.sh fix info on failed restore Output SQL commands needed to setup database access. Change-Id: I212bfdd3b362880faa7aee159866d928de83d6f3 Bug-Url: https://bugzilla.redhat.com/1021448 Signed-off-by: Yedidyah Bar David <d...@redhat.com> --- M packaging/bin/engine-backup.sh 1 file changed, 31 insertions(+), 3 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/74/20374/1 diff --git a/packaging/bin/engine-backup.sh b/packaging/bin/engine-backup.sh index e79edbd..5951c7b 100755 --- a/packaging/bin/engine-backup.sh +++ b/packaging/bin/engine-backup.sh @@ -56,6 +56,9 @@ db database only --file=FILE file to use during backup or restore --log=FILE log file to use + --sql-file=FILE Use with '--mode=restore' when it fails + to write to FILE SQL commands to let + restore access the database. --change-db-credentials activate the following options, to restore the database to a different location etc. If used, existing credentials are ignored. @@ -73,6 +76,7 @@ MODE= SCOPE=all +SQL_FILE= CHANGE_DB_CREDENTIALS= MY_DB_HOST= MY_DB_PORT=5432 @@ -108,6 +112,9 @@ ;; --log=*) LOG="${v}" + ;; + --sql-file=*) + SQL_FILE="${v}" ;; --change-db-credentials) CHANGE_DB_CREDENTIALS=1 @@ -268,6 +275,21 @@ load_config fi + if [ -n "${SQL_FILE}" ]; then + if ! [ -e "${SQL_FILE}" ]; then + touch "${SQL_FILE}" + chmod 600 "${SQL_FILE}" + fi + cat << __EOF__ > "${SQL_FILE}" +-- Do the following on host ${ENGINE_DB_HOST} . +-- Make sure that database can be accessed remotely on port ${ENGINE_DB_PORT} . +create user ${ENGINE_DB_USER} password '${ENGINE_DB_PASSWORD}'; +create database ${ENGINE_DB_DATABASE} owner ${ENGINE_DB_USER} template template0 +encoding 'UTF8' lc_collate 'en_US.UTF-8' +lc_ctype 'en_US.UTF-8'; +__EOF__ + fi + log "Generating pgpass" generatePgPass # Must run after configuration reload log "Verifying connection" @@ -282,15 +304,21 @@ } verifyConnection() { - PGPASSFILE="${MYPGPASS}" psql \ + if ! PGPASSFILE="${MYPGPASS}" psql \ -w \ -U "${ENGINE_DB_USER}" \ -h "${ENGINE_DB_HOST}" \ -p "${ENGINE_DB_PORT}" \ -d "${ENGINE_DB_DATABASE}" \ -c "select 1" \ - >> "${LOG}" 2>&1 \ - || logdie "Can't connect to the database" + >> "${LOG}" 2>&1 + then + if [ -z "${SQL_FILE}" ]; then + output "Use --sql-file=FILE to get SQL commands for" + output "providing access to the database" + fi + logdie "Can't connect to the database" + fi } verifyVersion() { -- To view, visit http://gerrit.ovirt.org/20374 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I212bfdd3b362880faa7aee159866d928de83d6f3 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Yedidyah Bar David <d...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches