Just an update, I was able to get NextCloud converted over. Dumping the existing mysql database with PostgreSQL compatibility did not work. I'm next going to test out user mapping via cloudron LDAP and once that is complete I'll update all my notes into a more readable format. But the process was essentially this:
-
Have a fresh NextCloud App running on Cloudron and immediately enter recovery mode
-
Bring up a temporary machine running PostgreSQL
-
Build pgloader on the temporary PostgreSQL Server
- sudo apt install sbcl unzip libsqlite3-dev gawk curl make freetds-dev libzip-dev
- curl -fsSLO https://github.com/dimitri/pgloader/archive/v3.6.2.tar.gz
- tar xvf v3.6.2.tar.gz
- cd pgloader-3.6.2/
- make pgloader
- sudo mv ./build/bin/pgloader /usr/local/bin/
-
Create a postgres user
- sudo -u postgres createuser --interactive -P
- <NewPostgresUser>(username)
- Set the password for this role <NewPostgresPassword>
- Make the user a super user
-
Create an empty postgres DB
- sudo -u postgres createdb <emptyDBName>
-
Create a user on the MySQLDB and give it all privileges to the NextCloud DB
- mysql> CREATE USER ‘<someMySQLUserName>’@’<postgersServerIP’ IDENTIFIED BY ‘<SomeMySQLUserPassword>’
- mysql> GRANT ALL ON <nextcloudDB>.* to ‘<someMySQLUserName>’@’<postgresServerIP>’;
- mysql> flush privileges;
-
From the PostgreSQL Server ran pgloader
- pgloader mysql://<someMySQLUserName>:<SomeMySQLUserPassword>@mysql_server_ip/<nextcloudDB> postgresql://<NewPostgresUser>:<NewPostgresPassword>@localhost/<emptyDBName>
-
Dump the PostgreSQL Database
- pg_dump <emptyDBName> > pgdump.sql
-
Get CLOUDRON_POSTGRESQL_USERNAME from the app container running the NextCloud APP.
-
sed the .sql file and replace the schema with public
-
sed the .sql file and replace the <table owners> with CLOUDRON_POSTGRESQL_USERNAME
-
Open a web terminal to the NextCloud App that is in recovery mode and upload the .sql file via the Upload to /tmp button
-
Run the following commands grabbed from https://docs.cloudron.io/guides/import-postgresql/
- sed -e 's/CREATE EXTENSION/-- CREATE EXTENSION/g' -e 's/COMMENT ON EXTENSION/-- COMMENT ON EXTENSION/g' /tmp/pgdump.sql > /tmp/pgdump_mod.sql
- PGPASSWORD=${CLOUDRON_POSTGRESQL_PASSWORD} psql -h ${CLOUDRON_POSTGRESQL_HOST} -p ${CLOUDRON_POSTGRESQL_PORT} -U ${CLOUDRON_POSTGRESQL_USERNAME} -d ${CLOUDRON_POSTGRESQL_DATABASE} -c "DROP SCHEMA public CASCADE; CREATE SCHEMA public"
- PGPASSWORD=${CLOUDRON_POSTGRESQL_PASSWORD} psql -h ${CLOUDRON_POSTGRESQL_HOST} -p ${CLOUDRON_POSTGRESQL_PORT} -U ${CLOUDRON_POSTGRESQL_USERNAME} -d ${CLOUDRON_POSTGRESQL_DATABASE} --set ON_ERROR_STOP=on --file=/tmp/pgdump_mod.sql
-
Move just the data from the old NextCloud server into the data directory of the NextCloud App on Cloudron. This is found in the app’s config page | Storage Section, should be something like:
/home/yellowtent/appsdata/<containerHash>/data -
Bring the container out of recovery and boot up
Again, I'll update these notes if/when I try again and get cloudron's LDAP to map to the users in the database but for now, maybe these steps will help someone looking to convert and existing installation over to a Cloudron app.