blob: 790032768c59a408c3e742f0a6f1ec204585a0f8 [file] [log] [blame]
Thomas Vachuska58bf4912017-10-31 12:00:32 -07001#!/bin/bash
2# -----------------------------------------------------------------------------
3# ONOS utility to restore persistent data from a backup archive.
4# -----------------------------------------------------------------------------
5
6ONOS_HOME=${ONOS_HOME:-$(cd $(dirname $0)/.. >/dev/null 2>&1 && pwd)}
7ONOS_DEFAULT_ARCHIVE=$(dirname $ONOS_HOME)/onos-data.tar.gz
Ray Milkey73d93002020-07-06 11:30:36 -07008ONOS_KARAF=$ONOS_HOME/apache-karaf-4.2.9
Thomas Vachuska58bf4912017-10-31 12:00:32 -07009
10# Fetch the name of the archive or use a default if none is specified
11archive=${1:-$ONOS_DEFAULT_ARCHIVE}
12archive=$(cd "$(dirname "$1")"; pwd)/$(basename "$1")
13
14# Make sure that the apache karaf data directory exists
15[ ! -d $ONOS_KARAF/data ] && echo "ONOS data directory not found" && exit 1
16
17# Make sure that the archive lies outside of $ONOS_HOME for safety
18[[ "$archive" =~ ^$ONOS_HOME/.* ]] && \
19 echo "Archive cannot be in $ONOS_HOME directory tree" && exit 1
20
21# Make sure that the archive file exists
22[ ! -f $archive ] && echo "Archive $archive not found" && exit 1
23
24# Now unroll the archive into the data directory tree
25cd $ONOS_KARAF
26tar zxf $archive