2013-02-16 14:29:48 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
do_extract() {
|
|
|
|
# List the files and check if grep hits something
|
|
|
|
SEARCH=`tar -tvf $1 | grep $2`
|
|
|
|
RES=$?
|
|
|
|
if [ $RES = 0 ]; then
|
2014-08-26 17:28:33 +00:00
|
|
|
tar --transform='s,^content/,,' -C / -xvf $1 $2
|
2013-02-16 14:29:48 +00:00
|
|
|
else
|
|
|
|
echo "Directory '$2' is not in backup '$1'."
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
do_restore_files() {
|
|
|
|
BACKUP_FILE=$1
|
|
|
|
if [ ! -e "$BACKUP_FILE" ] ; then
|
|
|
|
echo "The backup file '$BACKUP_FILE' does not exist. Exiting!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Going to extract files from the backup '$BACKUP_FILE'"
|
|
|
|
do_extract $BACKUP_FILE content/etc
|
|
|
|
do_extract $BACKUP_FILE content/var/lib/osmocom
|
|
|
|
}
|
|
|
|
|
|
|
|
do_restore_files $1
|