Eli Mesika has uploaded a new change for review.

Change subject: core:  exportDbSchema scripts generates output...
......................................................................

core:  exportDbSchema scripts generates output...

exportDbSchema scripts generates output file with wrong name

1) Fixing the file name by using psql directly
2) Fixing -v to display more info
3) Adding a missing PORT parameter

Change-Id: I3d05e96f4abc66e293db23af89285b0653025537
iBug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1009899
Signed-off-by: Eli Mesika <[email protected]>
---
M packaging/dbscripts/exportDbSchema.sh
1 file changed, 10 insertions(+), 3 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/79/19679/1

diff --git a/packaging/dbscripts/exportDbSchema.sh 
b/packaging/dbscripts/exportDbSchema.sh
index 41fe710..4e2b7c9 100755
--- a/packaging/dbscripts/exportDbSchema.sh
+++ b/packaging/dbscripts/exportDbSchema.sh
@@ -6,11 +6,13 @@
 
 #setting defaults
 set_defaults
+VERBOSE=false
 
 usage() {
-    printf "Usage: ${ME} [-h] [-s SERVERNAME] [-d DATABASE] [-u USERNAME] 
[-v]\n"
+    printf "Usage: ${ME} [-h] [-s SERVERNAME] [-p PORT] [-d DATABASE] [-u 
USERNAME] [-v]\n"
     printf "\n"
     printf "\t-s SERVERNAME - The database servername for the database (def. 
${SERVERNAME})\n"
+    printf "\t-p PORT       - The database servername port for the database 
(def. ${PORT})\n"
     printf "\t-d DATABASE   - The database name                        (def. 
${DATABASE})\n"
     printf "\t-u USERNAME   - The username for the database            (def. 
engine)\n"
     printf "\t-l LOGFILE    - The logfile for capturing output         (def. 
${LOGFILE}\n"
@@ -30,6 +32,7 @@
 while getopts hs:d:u:p:l:v option; do
     case $option in
         s) SERVERNAME=$OPTARG;;
+        p) PORT=$OPTARG;;
         d) DATABASE=$OPTARG;;
         u) USERNAME=$OPTARG;;
         l) LOGFILE=$OPTARG;;
@@ -40,9 +43,13 @@
 done
 
 CMD="select version from schema_version where current;"
-VERSION=$(execute_command "$CMD" ${DATABASE} ${SERVERNAME} ${PORT} | sed 's/^ 
*//g')
+VERSION=$(psql -w -U ${USERNAME} --pset=tuples_only=on ${DATABASE} -h 
${SERVERNAME} -p ${PORT} -c "${CMD}" | sed 's/^ *//g')
 FILE=".${DATABASE}.${VERSION}.schema"
-pg_dump -f "${FILE}" -F p -n public -s -U ${USERNAME} ${DATABASE} -h 
${SERVERNAME} -p ${PORT}  >& /dev/null
+if [[ "${VERBOSE}" = "true" ]]; then
+    pg_dump -f "${FILE}" -F p -n public -s -U ${USERNAME} ${DATABASE} -h 
${SERVERNAME} -p ${PORT}  -v
+else
+    pg_dump -f "${FILE}" -F p -n public -s -U ${USERNAME} ${DATABASE} -h 
${SERVERNAME} -p ${PORT}
+fi
 
 printf "Done.\n"
 printf "Exported file is ${FILE}.\n"


-- 
To view, visit http://gerrit.ovirt.org/19679
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I3d05e96f4abc66e293db23af89285b0653025537
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Eli Mesika <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to