-
wrote on Aug 15, 2018, 7:35 AM last edited by
I want to migrate my Nextcloud installation to Cloudron but want to keep the already existing users (incl. password - I do not want to use the Cloudron authentication for Nextcloud) and settings (shares, permissions, extensions, ...). How can I do that?
-
Unfortunately, I don't think there is some automated way to do this, yet. However you can install the nextcloud app on your Cloudron and select
Leave user management to the app
during installation, then you somehow have to export and import the database backup. You can get a remote shell connection into the Cloudron app via the dashboard and https://cloudron.io/documentation/apps/nextcloud/#running-occ-tool mentions how to run occ correctly. Regarding importing the files with potentially setup share/access permissions, I am not sure myself how to do this correctly. Maybe there are upstream migration guides which handle that case? -
Unfortunately, I don't think there is some automated way to do this, yet. However you can install the nextcloud app on your Cloudron and select
Leave user management to the app
during installation, then you somehow have to export and import the database backup. You can get a remote shell connection into the Cloudron app via the dashboard and https://cloudron.io/documentation/apps/nextcloud/#running-occ-tool mentions how to run occ correctly. Regarding importing the files with potentially setup share/access permissions, I am not sure myself how to do this correctly. Maybe there are upstream migration guides which handle that case? -
wrote on Nov 10, 2018, 9:14 PM last edited by
Yes, it worked. Unfortunately I did no document every step in detail, there were many steps involved. Here are they key steps, it's not a list which can be followed step-by-step, one has to figure out the details by himself:
- Export DB from old installation (mine was MariaDB)
- Start a temporary DB server on the Cloudron server and import the DB, something like:
docker run -d --name=mariadb -v mariadb-temp:/var/lib/mysql -v /tmp/dump:/data -p 3308:3306 -e MYSQL_ROOT_PASSWORD=password --network=cloudron mariadb:10.1
- Login to your Nextcloud container:
cloudron exec --app files.example.com -t bash
- Update the Nextcloud configuration to point to this temporary DB server and have the exact same version as the old installation. Example (replace values with the ones of your installation):
... 'dbtype' => 'mysql', 'version' => '13.0.0.14', 'dbname' => 'nextcloud', 'dbhost' => '172.18.0.10', 'dbport' => '3306', 'dbtableprefix' => 'oc_', 'dbuser' => 'root', 'dbpassword' => 'password', ...
- Run migration:
sudo -u www-data php occ db:convert-type --clear-schema --all-apps --password ${POSTGRESQL_PASSWORD} pgsql ${POSTGRESQL_USERNAME} ${POSTGRESQL_HOST} ${POSTGRESQL_DATABASE} sudo -u www-data php occ upgrade
- Move your data from the old to the new Cloudron server
- Remove temporary DB server and it's data
It's not very straight forward, but definitively doable.
-
Thanks for the reply! Definitely a great start, we will take it from there and refine it to put in our documentation to get more people started.
wrote on Jan 23, 2022, 6:38 PM last edited by SolarSimon Jan 24, 2022, 2:58 PMhas anybody else succeeded to migrate nextcloud?
For me this could be the key step to move to cloudron premiumAbout @tobru steps:
I succedded to install mariadb and import my DB.
But already a compromise: Either use different port than 3306 or kill the running process behind mysqlI had several approaches, like changing port, enable remote access to mariadb. But I always fail to convert with 'occ db:convert-type'
Giving me the message:SQLSTATE[HY000] [2002] Connection timed out in /app/code/lib/private/DB/Connection.php:87
I guess i have to find the right way to configure mariadb and the containers to access the database. Setting up Docker Network, but need guidance here refering the cloudron setup.
My config.php:
'dbtype' => 'mysql', 'version' => '22.2.3.0', 'overwrite.cli.url' => 'https://url', 'overwriteprotocol' => 'https', 'dbname' => 'nextcloud', 'dbhost' => '172.17.0.2', 'dbport' => '3308', 'dbtableprefix' => 'oc_', 'dbuser' => 'nextclouduser', 'dbpassword' => 'xxxxxxxx',
-
has anybody else succeeded to migrate nextcloud?
For me this could be the key step to move to cloudron premiumAbout @tobru steps:
I succedded to install mariadb and import my DB.
But already a compromise: Either use different port than 3306 or kill the running process behind mysqlI had several approaches, like changing port, enable remote access to mariadb. But I always fail to convert with 'occ db:convert-type'
Giving me the message:SQLSTATE[HY000] [2002] Connection timed out in /app/code/lib/private/DB/Connection.php:87
I guess i have to find the right way to configure mariadb and the containers to access the database. Setting up Docker Network, but need guidance here refering the cloudron setup.
My config.php:
'dbtype' => 'mysql', 'version' => '22.2.3.0', 'overwrite.cli.url' => 'https://url', 'overwriteprotocol' => 'https', 'dbname' => 'nextcloud', 'dbhost' => '172.17.0.2', 'dbport' => '3308', 'dbtableprefix' => 'oc_', 'dbuser' => 'nextclouduser', 'dbpassword' => 'xxxxxxxx',
@solarsimon The first step is to export your existing installation's database. Have you done this already? Note that the Cloudron package uses PostgreSQL. Are you using MySQL in your existing instance? If so, you will have convert it somehow.
There's also a guide here - https://docs.cloudron.io/guides/import-postgresql/
-
@solarsimon The first step is to export your existing installation's database. Have you done this already? Note that the Cloudron package uses PostgreSQL. Are you using MySQL in your existing instance? If so, you will have convert it somehow.
There's also a guide here - https://docs.cloudron.io/guides/import-postgresql/
wrote on Jan 25, 2022, 11:42 AM last edited by SolarSimon Jan 25, 2022, 11:43 AMThis post is deleted! -
@solarsimon The first step is to export your existing installation's database. Have you done this already? Note that the Cloudron package uses PostgreSQL. Are you using MySQL in your existing instance? If so, you will have convert it somehow.
There's also a guide here - https://docs.cloudron.io/guides/import-postgresql/
wrote on Jan 30, 2022, 2:22 PM last edited by@girish said in Migrate Nextcloud - Keep Nextcloud Users and Settings:
you will have convert it somehow.
I did some relevant steps futher to migration. Nextcloud is running with my data, database and apps on cloudron. So far pretty nice.
One more issue in detail:
All Files get a new FileID. Thats a big problem, cus file-links don't work anymore, both internal and external.
Anybody got a hint? Gonna ask in the nextcloud community.For those how want to migrate, some further information.
On my System (Ubuntu 20, php7.4, mariadb10.5, Nextcloud 22) I installed PostgreSQL. Then convert database by occ db:convert...sudo -u www-data php /var/www/nextcloud/occ db:convert-type --clear-schema --all-apps pgsql nextclouduser 127.0.0.1 nextcloud
Than make your Database setting equivalent to cloudron setting (u find them in config.php)
sudo -u postgres psql ALTER DATABASE nextcloud RENAME TO db8fe...; ALTER ROLE nextclouduser RENAME TO user8fe...; ALTER ROLE user8fe... WITH PASSWORD 'f99...'; \q
postgres said something about crashing md5
so i switched to "trust" in pg_hba.conf
https://confluence.atlassian.com/confkb/how-to-change-the-postgresql-administrator-password-693900817.htmlcreate your dump
pg_dump -Fp -h 127.0.0.1 -U user8fe... db8fe... -f /home/backup/nextcloudpg.sql
Sync your data-folder and your apps-folder.
Then follow https://docs.cloudron.io/guides/import-postgresql/ -
@girish said in Migrate Nextcloud - Keep Nextcloud Users and Settings:
you will have convert it somehow.
I did some relevant steps futher to migration. Nextcloud is running with my data, database and apps on cloudron. So far pretty nice.
One more issue in detail:
All Files get a new FileID. Thats a big problem, cus file-links don't work anymore, both internal and external.
Anybody got a hint? Gonna ask in the nextcloud community.For those how want to migrate, some further information.
On my System (Ubuntu 20, php7.4, mariadb10.5, Nextcloud 22) I installed PostgreSQL. Then convert database by occ db:convert...sudo -u www-data php /var/www/nextcloud/occ db:convert-type --clear-schema --all-apps pgsql nextclouduser 127.0.0.1 nextcloud
Than make your Database setting equivalent to cloudron setting (u find them in config.php)
sudo -u postgres psql ALTER DATABASE nextcloud RENAME TO db8fe...; ALTER ROLE nextclouduser RENAME TO user8fe...; ALTER ROLE user8fe... WITH PASSWORD 'f99...'; \q
postgres said something about crashing md5
so i switched to "trust" in pg_hba.conf
https://confluence.atlassian.com/confkb/how-to-change-the-postgresql-administrator-password-693900817.htmlcreate your dump
pg_dump -Fp -h 127.0.0.1 -U user8fe... db8fe... -f /home/backup/nextcloudpg.sql
Sync your data-folder and your apps-folder.
Then follow https://docs.cloudron.io/guides/import-postgresql/wrote on Jan 31, 2022, 6:24 PM last edited by SolarSimon Jan 31, 2022, 6:25 PM@solarsimon said in Migrate Nextcloud - Keep Nextcloud Users and Settings:
One more issue in detail:
All Files get a new FileID. Thats a big problem, cus file-links don't work anymore, both internal and external.
Anybody got a hint? Gonna ask in the nextcloud community.solved!
Make sure your data folder has the same folder structure.
Otherwise (in general when changing data folder) nextcloud does a rescan.In my case I had to move all my data to new folder (media/storage) before I dump the database
Step by step:
- maintenance mode and move data folder
- update database
sudo -u postgres psql \c db8fe... UPDATE public.oc_storages SET id = 'local::/media/storage/' WHERE id = 'local::/home/data/';
- update config.php
Maybe you can save work, by just alter the oc_storages in your database on your new server after import. But I did not try.
I also copied 'passwordsalt' and 'secret' in config.php from the old to the new server.
-
@solarsimon said in Migrate Nextcloud - Keep Nextcloud Users and Settings:
One more issue in detail:
All Files get a new FileID. Thats a big problem, cus file-links don't work anymore, both internal and external.
Anybody got a hint? Gonna ask in the nextcloud community.solved!
Make sure your data folder has the same folder structure.
Otherwise (in general when changing data folder) nextcloud does a rescan.In my case I had to move all my data to new folder (media/storage) before I dump the database
Step by step:
- maintenance mode and move data folder
- update database
sudo -u postgres psql \c db8fe... UPDATE public.oc_storages SET id = 'local::/media/storage/' WHERE id = 'local::/home/data/';
- update config.php
Maybe you can save work, by just alter the oc_storages in your database on your new server after import. But I did not try.
I also copied 'passwordsalt' and 'secret' in config.php from the old to the new server.
@solarsimon Thanks for the write up! Sorry, I couldn't assist further since I have not done such a migration myself
-
@solarsimon Thanks for the write up! Sorry, I couldn't assist further since I have not done such a migration myself
wrote on Jul 26, 2022, 11:48 AM last edited byjust an update, the syntax for the psql variables has changed, so the conversion script looks like this:
sudo -u www-data php occ db:convert-type \ --password ${CLOUDRON_POSTGRESQL_PASSWORD} \ --clear-schema --all-apps pgsql \ ${CLOUDRON_POSTGRESQL_USERNAME} \ ${CLOUDRON_POSTGRESQL_HOST} \ ${CLOUDRON_POSTGRESQL_DATABASE}
you must run this from within the nextcloud container.
also, I had some dificulties with the mysql migration, the temp mariadb/mysql docker container should match the same type and version as the source. In my case src had mariadb 10.5, so the container from the code sample above (mariadb 10.1) throw some strange errors while importing the sql dump.