Skip to content

Commit

Permalink
nc-restore: restore db password before occ command
Browse files Browse the repository at this point in the history
  • Loading branch information
nachoparker committed Oct 31, 2017
1 parent 6fdb761 commit 706a48d
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions etc/nextcloudpi-config.d/nc-restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,18 @@ configure()

local TMPDIR="$( dirname $BACKUPFILE_ )/$( basename ${BACKUPFILE_}-tmp )"
rm -rf "$TMPDIR" && mkdir -p "$TMPDIR"

echo -e "extracting backup file $BACKUPFILE_..."
tar -xf "$BACKUPFILE_" -C "$TMPDIR" || return 1

## RESTORE FILES

echo -e "restore files..."
rm -rf $BASEDIR/nextcloud
mv "$TMPDIR"/nextcloud $BASEDIR
mv "$TMPDIR"/nextcloud $BASEDIR || { echo -e "Error restoring base files"; return 1; }

# update NC database password to this instance
sed -i "s|'dbpassword' =>.*|'dbpassword' => '$DBPASSWD',|" config/config.php

## RE-CREATE DATABASE TABLE

Expand Down Expand Up @@ -78,6 +83,10 @@ EOF
}
mkdir -p "$( dirname "$DATADIR" )"
mv "$TMPDIR/$( basename "$DATADIR" )" "$DATADIR"

# Just in case we moved the opcache dir
sed -i "s|^opcache.file_cache=.*|opcache.file_cache=$DATADIR/.opcache|" /etc/php/7.0/mods-available/opcache.ini

sudo -u www-data php occ maintenance:mode --off

# INCLUDEDATA=no situation
Expand All @@ -86,6 +95,9 @@ EOF
echo -e "no datadir found in backup"
sed -i "s|'datadirectory' =>.*|'datadirectory' => '/var/www/nextcloud/data',|" config/config.php

# Just in case we moved the opcache dir
sed -i "s|^opcache.file_cache=.*|opcache.file_cache=$BASEDIR/nextcloud/data/.opcache|" /etc/php/7.0/mods-available/opcache.ini

sudo -u www-data php occ maintenance:mode --off
sudo -u www-data php occ files:scan --all

Expand All @@ -100,12 +112,6 @@ EOF
" &>/dev/null &
fi
rm -r "$TMPDIR"

# update NC database password to this instance
sed -i "s|'dbpassword' =>.*|'dbpassword' => '$DBPASSWD',|" config/config.php

# Just in case we moved the opcache dir
sed -i "s|^opcache.file_cache=.*|opcache.file_cache=$BASEDIR/nextcloud/data/.opcache|" /etc/php/7.0/mods-available/opcache.ini
}

install() { :; }
Expand Down

0 comments on commit 706a48d

Please sign in to comment.