This is an old revision of the document!


Moving a Next Cloud Datastore

this is particularly useful if you've used turnkey linux, or if you've installed nextcloud on a VM and want to move the storage to a NAS

ref: https://help.nextcloud.com/t/howto-change-move-data-directory-after-installation/17170

turn maintenance mode on for nextcloud:

sudo -u www-data php /path/to/nextcloud/occ maintenance:mode --on

make a new directory for your data, copy your data to it, and have nextcloud's user take ownership:

mkdir -p /new/path/to/data
cp -a /path/to/data/. /new/path/to/data
chown -R www-data:www-data /new/path/to/data

modify nextcloud config to point to this new path:

nano /path/to/nextcloud/config/config.php
       'datadirectory' => '/new/path/to/data',

change the location in the database:

mysqldump -u<rootuser> -p > /path/to/dbdump/dump.sql
dbuser=$(awk -F\' "/'dbuser'/{print \$4;exit}" /path/to/nextcloud/config/config.php)
      dbpassword=$(awk -F\' "/'dbpassword'/{print \$4;exit}" /var/www/nextcloud/config/config.php)
      mysql -u$dbuser -p$dbpassword

Inside the MySQL console:

    <code>use <nextclouddb>;
    update oc_storages set id='local::/new/path/to/data/' where id='local::/path/to/data/'; //take care about backslash at the end of path!!
    quit;</code>

Again outside the MySQL console

    <code>unset dbuser dbpassword

</code>







Discussion

Enter your comment. Wiki syntax is allowed:
 
Last modified: le 2022/03/01 18:42