Yedidyah Bar David has uploaded a new change for review. Change subject: packaging: Fix problems in engine-backup.sh ......................................................................
packaging: Fix problems in engine-backup.sh Backup more files Change SCOPE's dbonly to db everywhere Do not fail if some files are missing (e.g. /etc/firewalld/services/ovirt-postgres.xml is not always created by setup). Fix selinux contexts Change-Id: I464e795627af23712696212e4589e4b8480bb8a0 Bug-Url: https://bugzilla.redhat.com/1020277 Signed-off-by: Yedidyah Bar David <d...@redhat.com> --- M packaging/bin/engine-backup.sh 1 file changed, 46 insertions(+), 26 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/64/20264/1 diff --git a/packaging/bin/engine-backup.sh b/packaging/bin/engine-backup.sh index a2b7b09..e6133fc 100755 --- a/packaging/bin/engine-backup.sh +++ b/packaging/bin/engine-backup.sh @@ -20,10 +20,17 @@ . "$(dirname "$(readlink -f "$0")")"/engine-prolog.sh # Globals -BACKUP_FOLDERS="/etc/ovirt-engine +BACKUP_PATHS="/etc/ovirt-engine /etc/pki/ovirt-engine /etc/ovirt-engine-setup.conf.d -/var/lib/ovirt-engine" +/var/lib/ovirt-engine +/etc/httpd/conf.d/ovirt-engine-root-redirect.conf +/etc/httpd/conf.d/ssl.conf +/etc/httpd/conf.d/z-ovirt-engine-proxy.conf +/etc/yum/pluginconf.d/versionlock.list +/etc/firewalld/services/ovirt-https.xml +/etc/firewalld/services/ovirt-http.xml +/etc/firewalld/services/ovirt-postgres.xml" MYPGPASS="" TEMP_FOLDER="" FILE="" @@ -42,19 +49,19 @@ USAGE: $0 [--mode=MODE] [--scope=SCOPE] [--file=FILE] [--log=FILE] MODE is one of the following: - backup backup system into FILE - restore restore system from FILE + backup backup system into FILE + restore restore system from FILE SCOPE is one of the following: - all complete backup/restore - db database only - --file=FILE file to use during backup or restore - --log=FILE log file to use + all complete backup/restore (default) + db database only + --file=FILE file to use during backup or restore + --log=FILE log file to use __EOF__ return 0 } MODE= -SCOPE= +SCOPE=all parseArgs() { while [ -n "$1" ]; do @@ -72,7 +79,7 @@ --scope=*) SCOPE="${v}" case "${SCOPE}" in - all|dbonly) ;; + all|db) ;; *) die "invalid scope '${SCOPE}'" esac ;; @@ -115,9 +122,9 @@ mkdir "${tardir}/${FILES}" || logdie "Cannot create '${tardir}/files'" mkdir "${tardir}/db" || logdie "Cannot create '${tardir}/db'" - if [ "${SCOPE}" != "dbonly" ] ; then + if [ "${SCOPE}" != "db" ] ; then log "Backing up files to ${tardir}/files" - backupFiles "${BACKUP_FOLDERS}" "${tardir}/files" + backupFiles "${BACKUP_PATHS}" "${tardir}/files" fi log "Backing up database to ${tardir}/db/${DB_BACKUP_FILE_NAME}" @@ -150,13 +157,17 @@ } backupFiles() { - local folders="$1" + local paths="$1" local target="$2" - echo "${folders}" | while read folder; do - local dirname="$(dirname ${folder})" - mkdir -p "${tardir}/files/${dirname}" || logdie "Cannot create '${tardir}/files/${dirname}" - cp -a "${folder}" "${target}/${dirname}" || logdie "Cannot copy ${folder} to ${target}/${dirname}" - done || logdie "Cannot read ${folders}" + echo "${paths}" | while read path; do + if [ -e "${path}" ]; then + local dirname="$(dirname ${path})" + mkdir -p "${tardir}/files/${dirname}" || logdie "Cannot create '${tardir}/files/${dirname}" + cp -a "${path}" "${target}/${dirname}" || logdie "Cannot copy ${path} to ${target}/${dirname}" + else + echo "Skipping not-existent ${path}" + fi + done || logdie "Cannot read ${paths}" } backupDB() { @@ -184,9 +195,9 @@ log "Verifying version" verifyVersion - if [ "${SCOPE}" != "dbonly" ] ; then + if [ "${SCOPE}" != "db" ] ; then log "Restoring files" - restoreFiles "${BACKUP_FOLDERS}" + restoreFiles "${BACKUP_PATHS}" fi log "Reloading configuration" @@ -197,6 +208,10 @@ verifyConnection log "Restoring database backup at ${TEMP_FOLDER}/db/${DB_BACKUP_FILE_NAME}" restoreDB "${TEMP_FOLDER}/db/${DB_BACKUP_FILE_NAME}" + output "Starting services:" + service ovirt-engine start + service httpd restart + output "Note: you might need to manually fix iptables/firewalld conf and autostart of ovirt-engine service" } verifyConnection() { @@ -232,12 +247,17 @@ } restoreFiles() { - local folders="$1" - echo "${folders}" | while read folder; do - local dirname="$(dirname ${folder})" - local backup="${TEMP_FOLDER}/files/${folder}" - cp -a "${backup}" "${dirname}" || logdie "Cannot copy '${backup}' to '${dirname}'" - done || logdie "Cannot read ${folders}" + local paths="$1" + echo "${paths}" | while read path; do + local dirname="$(dirname ${path})" + local backup="${TEMP_FOLDER}/files/${path}" + if ! [ -e "${backup}" ]; then + echo "Skipping not-existent ${path}" + else + cp -a "${backup}" "${dirname}" || logdie "Cannot copy '${backup}' to '${dirname}'" + selinuxenabled && restorecon -R "${path}" + fi + done || logdie "Cannot read ${paths}" } generatePgPass() { -- To view, visit http://gerrit.ovirt.org/20264 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I464e795627af23712696212e4589e4b8480bb8a0 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