Adding utilities for offline backup/restore.
Relocating local ECM caches and partitions under data/db directory.

Change-Id: I4790c7488765d8195496a1830abfca897129784c
diff --git a/tools/package/bin/onos-backup b/tools/package/bin/onos-backup
new file mode 100755
index 0000000..a37ee46
--- /dev/null
+++ b/tools/package/bin/onos-backup
@@ -0,0 +1,31 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# ONOS utility to produce a backup archive of all persistent data.
+# -----------------------------------------------------------------------------
+
+ONOS_HOME=${ONOS_HOME:-$(cd $(dirname $0)/.. >/dev/null 2>&1 && pwd)}
+ONOS_DEFAULT_ARCHIVE=$(dirname $ONOS_HOME)/onos-data.tar.gz
+ONOS_KARAF=$ONOS_HOME/apache-karaf-3.0.8
+
+# Fetch the name of the archive or use a default if none is specified
+archive=${1:-$ONOS_DEFAULT_ARCHIVE}
+archive=$(cd "$(dirname "$archive")"; pwd)/$(basename "$archive")
+
+# Make sure that the apache karaf data directory exists
+[ ! -d $ONOS_KARAF/data ] && echo "ONOS data directory not found" && exit 1
+
+# Make sure that the archive lies outside of $ONOS_HOME for safety
+[[ "$archive" =~ ^$ONOS_HOME/.* ]] && \
+    echo "Archive cannot be in $ONOS_HOME directory tree" && exit 1
+
+# Make sure that the archive file does not already exist
+[ -f $archive ] && echo "Archive $archive already exists" && exit 1
+
+# Make sure we can write the archive
+! touch $archive 2>/dev/null && \
+    echo "No permission to write archive $archive" && exit 1
+rm -f $archive
+
+# Now produce the archive using the subset of the data directory tree
+cd $ONOS_KARAF
+tar zcf $archive data/db data/log
diff --git a/tools/package/bin/onos-restore b/tools/package/bin/onos-restore
new file mode 100755
index 0000000..b7204e5
--- /dev/null
+++ b/tools/package/bin/onos-restore
@@ -0,0 +1,26 @@
+#!/bin/bash
+# -----------------------------------------------------------------------------
+# ONOS utility to restore persistent data from a backup archive.
+# -----------------------------------------------------------------------------
+
+ONOS_HOME=${ONOS_HOME:-$(cd $(dirname $0)/.. >/dev/null 2>&1 && pwd)}
+ONOS_DEFAULT_ARCHIVE=$(dirname $ONOS_HOME)/onos-data.tar.gz
+ONOS_KARAF=$ONOS_HOME/apache-karaf-3.0.8
+
+# Fetch the name of the archive or use a default if none is specified
+archive=${1:-$ONOS_DEFAULT_ARCHIVE}
+archive=$(cd "$(dirname "$1")"; pwd)/$(basename "$1")
+
+# Make sure that the apache karaf data directory exists
+[ ! -d $ONOS_KARAF/data ] && echo "ONOS data directory not found" && exit 1
+
+# Make sure that the archive lies outside of $ONOS_HOME for safety
+[[ "$archive" =~ ^$ONOS_HOME/.* ]] && \
+    echo "Archive cannot be in $ONOS_HOME directory tree" && exit 1
+
+# Make sure that the archive file exists
+[ ! -f $archive ] && echo "Archive $archive not found" && exit 1
+
+# Now unroll the archive into the data directory tree
+cd $ONOS_KARAF
+tar zxf $archive
diff --git a/tools/package/bin/onos-secure-ssh b/tools/package/bin/onos-secure-ssh
deleted file mode 100755
index fba3a03..0000000
--- a/tools/package/bin/onos-secure-ssh
+++ /dev/null
@@ -1,3 +0,0 @@
-#!/bin/bash
-echo "This command has been deprecated!"
-echo "Please use 'onos-user-key' and 'onos-user-password' commands instead."
\ No newline at end of file