Skip to content

Commit

Permalink
restore from other instance fix
Browse files Browse the repository at this point in the history
  • Loading branch information
nacho committed Aug 10, 2017
1 parent 9d4bcfe commit 2485242
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion etc/nextcloudpi-config.d/nc-init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ configure()

# workaround to emulate DROP USER IF EXISTS ..;)
local DBPASSWD=$( grep password /root/.my.cnf | cut -d= -f2 )
mysql -u root -p$DBPASSWD <<EOF
mysql -u root <<EOF
DROP DATABASE IF EXISTS nextcloud;
CREATE DATABASE nextcloud
CHARACTER SET utf8mb4
Expand Down
9 changes: 6 additions & 3 deletions etc/nextcloudpi-config.d/nc-restore.sh
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ configure()

local DBPASSWD=$( grep password /root/.my.cnf | cut -d= -f2 )
echo -e "restore database..."
mysql -u root -p$DBPASSWD <<EOF
mysql -u root <<EOF
DROP DATABASE IF EXISTS nextcloud;
CREATE DATABASE nextcloud;
GRANT USAGE ON *.* TO '$DBADMIN'@'localhost' IDENTIFIED BY '$DBPASSWD';
Expand All @@ -68,7 +68,7 @@ EXIT
EOF
[ $? -ne 0 ] && { echo -e "Error configuring nextcloud database"; return 1; }

mysql -u root -p$DBPASSWD nextcloud < "$TMPDIR"/nextcloud-sqlbkp_*.bak || { echo -e "Error restoring nextcloud database"; return 1; }
mysql -u root nextcloud < "$TMPDIR"/nextcloud-sqlbkp_*.bak || { echo -e "Error restoring nextcloud database"; return 1; }

## RESTORE DATADIR

Expand All @@ -89,7 +89,7 @@ EOF

else
echo -e "no datadir found in backup"
sed -i "s|'datadirectory' =>.*|'datadirectory' => '/var/www/nextcloud/data',|" "config/config.php"
sed -i "s|'datadirectory' =>.*|'datadirectory' => '/var/www/nextcloud/data',|" config/config.php

sudo -u www-data php occ maintenance:mode --off
sudo -u www-data php occ files:scan --all
Expand All @@ -106,6 +106,9 @@ EOF
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
}
Expand Down

0 comments on commit 2485242

Please sign in to comment.