Skip to content

Commit 2485242

Browse files
author
nacho
committed
restore from other instance fix
1 parent 9d4bcfe commit 2485242

File tree

2 files changed

+7
-4
lines changed

2 files changed

+7
-4
lines changed

etc/nextcloudpi-config.d/nc-init.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ configure()
4949

5050
# workaround to emulate DROP USER IF EXISTS ..;)
5151
local DBPASSWD=$( grep password /root/.my.cnf | cut -d= -f2 )
52-
mysql -u root -p$DBPASSWD <<EOF
52+
mysql -u root <<EOF
5353
DROP DATABASE IF EXISTS nextcloud;
5454
CREATE DATABASE nextcloud
5555
CHARACTER SET utf8mb4

etc/nextcloudpi-config.d/nc-restore.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ configure()
5757

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

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

7373
## RESTORE DATADIR
7474

@@ -89,7 +89,7 @@ EOF
8989

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

9494
sudo -u www-data php occ maintenance:mode --off
9595
sudo -u www-data php occ files:scan --all
@@ -106,6 +106,9 @@ EOF
106106
fi
107107
rm -r "$TMPDIR"
108108

109+
# update NC database password to this instance
110+
sed -i "s|'dbpassword' =>.*|'dbpassword' => '$DBPASSWD',|" config/config.php
111+
109112
# Just in case we moved the opcache dir
110113
sed -i "s|^opcache.file_cache=.*|opcache.file_cache=$BASEDIR/nextcloud/data/.opcache|" /etc/php/7.0/mods-available/opcache.ini
111114
}

0 commit comments

Comments
 (0)