diff --git a/etc/nextcloudpi-config.d/nc-restore.sh b/etc/nextcloudpi-config.d/nc-restore.sh index 9c2b2fb68..9d3ad7236 100644 --- a/etc/nextcloudpi-config.d/nc-restore.sh +++ b/etc/nextcloudpi-config.d/nc-restore.sh @@ -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 @@ -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 @@ -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 @@ -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() { :; }