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


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps | Demo | Docs | Install
  1. Cloudron Forum
  2. Nextcloud
  3. Migrate Nextcloud - Keep Nextcloud Users and Settings

Migrate Nextcloud - Keep Nextcloud Users and Settings

Scheduled Pinned Locked Moved Solved Nextcloud
nextcloudmigrationusermanagement
13 Posts 5 Posters 3.7k Views 6 Watching
  • 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.
  • nebulonN nebulon

    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?

    tobruT Offline
    tobruT Offline
    tobru
    wrote on last edited by
    #3

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

    1 Reply Last reply
    0
    • nebulonN Offline
      nebulonN Offline
      nebulon
      Staff
      wrote on last edited by
      #4

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

      1 Reply Last reply
      0
      • tobruT Offline
        tobruT Offline
        tobru
        wrote on last edited by
        #5

        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
        1
        • nebulonN Offline
          nebulonN Offline
          nebulon
          Staff
          wrote on last edited by
          #6

          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
          1
          • nebulonN nebulon

            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 Offline
            S Offline
            SolarSimon
            wrote on last edited by SolarSimon
            #7

            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',
            
            girishG 1 Reply Last reply
            0
            • S 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',
              
              girishG Offline
              girishG Offline
              girish
              Staff
              wrote on last edited by
              #8

              @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
              1
              • girishG girish

                @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 Offline
                S Offline
                SolarSimon
                wrote on last edited by SolarSimon
                #9
                This post is deleted!
                1 Reply Last reply
                0
                • girishG girish

                  @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 Offline
                  S Offline
                  SolarSimon
                  wrote on last edited by
                  #10

                  @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
                  3
                  • S SolarSimon

                    @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 Offline
                    S Offline
                    SolarSimon
                    wrote on last edited by SolarSimon
                    #11

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

                    girishG 1 Reply Last reply
                    3
                    • S 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.

                      girishG Offline
                      girishG Offline
                      girish
                      Staff
                      wrote on last edited by
                      #12

                      @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
                      1
                      • girishG girish

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

                        P Offline
                        P Offline
                        perler
                        wrote on last edited by
                        #13

                        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
                        3
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Bookmarks
                        • Search