Ofer Schreiber has uploaded a new change for review.

Change subject: [WORK-IN-PROGRESS] packaging: Add backup and restore utility
......................................................................

[WORK-IN-PROGRESS] packaging: Add backup and restore utility

Initial add of ovirt-engine-bacup, a utility for backing up and
restoring an ovirt-engine environment.

Change-Id: I7f6c386a0f48ccd520978193639120999e00cf2a
Signed-off-by: Ofer Schreiber <[email protected]>
---
M Makefile
M ovirt-engine.spec.in
A packaging/bin/engine-backup.sh
3 files changed, 149 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/76/15276/1

diff --git a/Makefile b/Makefile
index c9e7aa2..8812e16 100644
--- a/Makefile
+++ b/Makefile
@@ -369,6 +369,10 @@
        ln -sf "$(DATA_DIR)/setup/bin/ovirt-engine-setup" 
"$(DESTDIR)$(BIN_DIR)/engine-setup-2"
        ln -sf "$(DATA_DIR)/setup/bin/ovirt-engine-remove" 
"$(DESTDIR)$(BIN_DIR)/engine-cleanup-2"
 
+       # Backup utility:
+       install -m 750 packaging/bin/engine-backup.sh $(DESTDIR)$(DATA_DIR)/bin
+       ln -sf $(DATA_DIR)/bin/engine-backup.sh 
$(DESTDIR)$(BIN_DIR)/engine-backup
+
 install_aio_plugin:
        install -m 644 packaging/fedora/setup/plugins/all_in_one_100.py 
$(DESTDIR)$(DATA_DIR)/scripts/plugins
        install -dm 755 $(DESTDIR)$(DATA_DIR)/firewalld/aio
diff --git a/ovirt-engine.spec.in b/ovirt-engine.spec.in
index 0921cf7..da00486 100644
--- a/ovirt-engine.spec.in
+++ b/ovirt-engine.spec.in
@@ -698,6 +698,7 @@
 %{_bindir}/engine-upgrade
 %{_bindir}/engine-check-update
 %{_bindir}/engine-cleanup
+%{_bindir}/engine-backup
 
 # Python scripts:
 %{engine_data}/scripts/basedefs.py*
@@ -745,6 +746,9 @@
 # Backups directory
 %dir %attr(-, %{engine_user}, %{engine_group}) %{engine_state}/backups
 
+# Backup script
+%{engine_data}/bin/engine-backup.sh
+
 %files setup-plugin-allinone
 %{engine_data}/scripts/plugins/all_in_one_100.py*
 %{engine_data}/firewalld/aio
diff --git a/packaging/bin/engine-backup.sh b/packaging/bin/engine-backup.sh
new file mode 100755
index 0000000..7e1dd51
--- /dev/null
+++ b/packaging/bin/engine-backup.sh
@@ -0,0 +1,141 @@
+#!/bin/sh
+#
+# This script is designed to backup and restore ovirt-engine environment.
+#
+
+# Load the prolog:
+#. "$(dirname "$(readlink -f "$0")")"/engine-prolog.sh
+
+BACKUP_FOLDERS="/etc/ovirt-engine /etc/pki/ovirt-engine"
+
+usage () {
+       cat << __EOF__
+engine-backup: backup and restore ovirt-engine
+USAGE:
+        engine-bacup [-b | --backup] [-r | --restore] [-d | --dbonly] [-f | 
--file=/path/to/bacup/or/restore/tarball]
+Where:
+        -b, --backup        perform backup
+        -r, --restore       perform restore
+        -d, --dbonly        handle only DB, ignore other configuration
+        -f, --file=         the file to use
+
+__EOF__
+       return 0
+}
+
+# TODO:
+# why do we need CONF_FILE here?
+# we do not use any vairable
+CONF_FILE="${ENGINE_ETC}/engine-config/engine-config.conf"
+BACKUP=false
+RESTORE=false
+DBONLY=false
+FILE=""
+
+parseArgs() {
+       while [ -n "$1" ]; do
+               local x="$1"
+               local v="${x#*=}"
+               shift
+               case "${x}" in
+                       -b)
+                               BACKUP=true
+                       ;;
+                       --backup)
+                               BACKUP=true
+                       ;;
+                       -h|-help|--help)
+                               usage
+                               exit 0
+                       ;;
+                       -r)
+                               RESTORE=true
+                       ;;
+                       --restore)
+                               RESTORE=true
+                       ;;
+                       -h|-help|--help)
+                               usage
+                               exit 0
+                       ;;
+
+                       -d)
+                               DBONLY=true
+                       ;;
+                       --dbonly)
+                               DBONLY=true
+                       ;;
+
+                       -f)
+                               FILE=$1
+                shift
+                       ;;
+                       --file=*)
+                               FILE="${v}"
+                       ;;
+               esac
+       done
+}
+
+verifyArgs() {
+    # Verify backup OR restore specified
+    if ! $BACKUP && ! $RESTORE ; then
+        echo "please specify -b or -r"
+        usage
+        exit 1
+    fi
+
+    # Verify a file has been given
+    if [ $RESTORE -a  ! -e $FILE ] ; then
+        echo "Restore file needed"
+        usage
+        exit 1
+    fi
+}
+
+generateTempFile() {
+    # Do nothing
+    echo "Generating Temp File"
+}
+
+doBackup() {
+    TEMP_FOLDER=$(mktemp -d)
+    CMD="tar czfv "
+
+
+# Iterate folders and add them to the tarball
+for folder in $BACKUP_FOLDERS; do
+    DIRNAME=$(dirname $folder)
+    mkdir -p $FILE/$DIRNAME
+    cp -R $folder $TEMP_FOLDER/$DIRNAME/
+
+    TARBALL=/tmp/engine-bakup_`uname -n`_`date +%Y_%m_%d_%H_%M_%S`.tgz
+done
+    # Create Tarball
+    $CMD $TARBALL -C $TEMP_FOLDER .
+}
+
+doRestore() {
+    echo "Restoring"
+}
+
+# do this in function so we do not lose $@
+parseArgs "$@"
+verifyArgs
+
+if [ -z $FILE ] ; then
+    generateTempFile
+fi
+
+if $BACKUP; then
+    doBackup
+fi
+
+if $RESTORE; then
+    doRestore
+fi
+
+#. "${CONF_FILE}"
+
+
+


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

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

Reply via email to