Skip to content
Snippets Groups Projects
Commit 1fe60565 authored by alvaro's avatar alvaro
Browse files

Added restore capabilities

parent 064002e5
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,7 @@ if [[ $# -eq 0 || "$1" == "--help" ]]; then ...@@ -9,7 +9,7 @@ if [[ $# -eq 0 || "$1" == "--help" ]]; then
fi fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
operations=( create delete debug backup ) operations=( create delete debug backup restore )
currentOperation= currentOperation=
if [[ ${operations[@]} =~ $1 ]]; then if [[ ${operations[@]} =~ $1 ]]; then
...@@ -25,6 +25,11 @@ if [[ $currentOperation == "backup" ]]; then ...@@ -25,6 +25,11 @@ if [[ $currentOperation == "backup" ]]; then
$DIR/modules/backup.sh $DIR/modules/backup.sh
fi fi
## Restore
if [[ $currentOperation == "restore" ]]; then
$DIR/modules/restore.sh
fi
## Create/delete ## Create/delete
if [[ $currentOperation == "create" || $currentOperation == "delete" ]]; then if [[ $currentOperation == "create" || $currentOperation == "delete" ]]; then
modules=( type service uri ) modules=( type service uri )
......
#!/bin/bash #!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
BACKUPDIR=$HOME/lodspeakr_backup cd $DIR
BASE=`php getvar.php basedir`
NAME=`echo $BASE |sed -e 's/^http:\/\///g' -e 's/\/$//g' -e 's/\//_/g'`
cd $DIR/../.. cd $DIR/../..
BACKUPDIR=$HOME/lodspeakr_backup
if [[ ! -d $BACKUPDIR ]]; then if [[ ! -d $BACKUPDIR ]]; then
echo "WARNING: No $BACKUPDIR dir. Creating it." >&2 echo "WARNING: No $BACKUPDIR dir. Creating it." >&2
mkdir $BACKUPDIR mkdir $BACKUPDIR
...@@ -13,7 +17,7 @@ if [[ ! -d $BACKUPDIR ]]; then ...@@ -13,7 +17,7 @@ if [[ ! -d $BACKUPDIR ]]; then
exit 1 exit 1
fi fi
tmpFile=lodspeakr_backup_`date +%Y%m%d%H%M%S`.tar.gz tmpFile=$NAME"-backup-"`date +%Y%m%d%H%M%S`.tar.gz
tar -czf $tmpFile settings.inc.php models views tar -czf $tmpFile settings.inc.php models views
......
<?
//error_reporting(E_ERROR);
require_once('../../settings.inc.php');
echo $conf[$argv[1]];
?>
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
BASE=`php getvar.php basedir`
NAME=`echo $BASE |sed -e 's/^http:\/\///g' -e 's/\/$//g' -e 's/\//_/g'`
cd $DIR/../..
BACKUPDIR=$HOME/lodspeakr_backup
if [[ ! -d $BACKUPDIR ]]; then
echo "ERROR: No $BACKUPDIR dir." >&2
exit 1
fi
LIST=( `ls $BACKUPDIR/$NAME-backup*` )
CHOSEN=-1
while [[ "$CHOSEN" -lt 0 || "$CHOSEN" -ge "${#LIST[@]}" ]] ;do
j=0
echo
echo "Choose from the following available backups"
for i in ${LIST[@]}; do
echo "["$j"]" `basename $i`
let j=$j+1
done
echo -n "Select which backup to restore: "
read -u 1 CHOSEN
done
echo
echo "*** ATTENTION ***"
echo "Are you sure you want to restore this backup? This may lead to overrite settings.inc.php, models/ and views/"
echo -n "(write 'yes' if you are sure): "
confirm=no
read confirm
if [[ "$confirm" != "yes" ]];then
echo "Nothing done"
exit 0
fi
RESTORE=`basename ${LIST[$CHOSEN]}`
echo "Restoring "$RESTORE"..."
cp ${LIST[$CHOSEN]} .
tar zxf $RESTORE
if [[ $? -eq 0 ]];then
echo Restore successful
else
echo A problem occurred in the restoring process
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment