Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


    Cloudron Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular

    Solved Migrate Nextcloud - Keep Nextcloud Users and Settings

    Nextcloud
    nextcloud migration usermanagement
    5
    13
    2102
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • tobru
      tobru 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?

      1 Reply Last reply Reply Quote 0
      • nebulon
        nebulon Staff last edited by

        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?

        tobru 1 Reply Last reply Reply Quote 0
        • tobru
          tobru @nebulon last edited by

          @nebulon Thanks for the hints. I'll give it a try and will report back once done...

          1 Reply Last reply Reply Quote 0
          • nebulon
            nebulon Staff last edited by

            @tobru did you try this and did it work out?

            1 Reply Last reply Reply Quote 0
            • tobru
              tobru 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.

              1 Reply Last reply Reply Quote 1
              • nebulon
                nebulon Staff last edited by

                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.

                S 1 Reply Last reply Reply Quote 1
                • S
                  SolarSimon @nebulon last edited by SolarSimon

                  has anybody else succeeded to migrate nextcloud?
                  For me this could be the key step to move to cloudron premium

                  About @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 mysql

                  I 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',
                  
                  girish 1 Reply Last reply Reply Quote 0
                  • girish
                    girish Staff @SolarSimon last edited by

                    @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/

                    S 2 Replies Last reply Reply Quote 1
                    • S
                      SolarSimon @girish last edited by SolarSimon

                      This post is deleted!
                      1 Reply Last reply Reply Quote 0
                      • S
                        SolarSimon @girish 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.html

                        create 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/

                        S 1 Reply Last reply Reply Quote 3
                        • S
                          SolarSimon @SolarSimon last edited by SolarSimon

                          @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:

                          1. maintenance mode and move data folder
                          2. update database
                          sudo -u postgres psql
                          \c db8fe...
                          UPDATE public.oc_storages SET id = 'local::/media/storage/' WHERE id = 'local::/home/data/';
                          
                          1. 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.

                          girish 1 Reply Last reply Reply Quote 3
                          • girish
                            girish Staff @SolarSimon last edited by

                            @solarsimon Thanks for the write up! Sorry, I couldn't assist further since I have not done such a migration myself 🙂

                            P 1 Reply Last reply Reply Quote 1
                            • P
                              perler @girish last edited by

                              just 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.

                              1 Reply Last reply Reply Quote 3
                              • First post
                                Last post
                              Powered by NodeBB