Scripted installation of Nextcloud 29 in iocage jail

Kind of. If you keep (but stop) the old jail, and give the script a new jail name, it will install a new jail using your existing jail. And yes, the current version of the script installs PHP 8.3.

right, so make my backups of everything (snapshots) , Shut down the nextcloud jail, give the script a different name in the nextcloud-config for the new jail (i don’t have to create this jail i assume?). (also, what happens if i dont give it a different name, leave it as nextcloud (because i might not want to change the jail name if i can get away with it, i have a backup snapshot so not worried)), will it still work as I’m expecting?

I should leave the entire /nextcloud dataset and its subsets just as they are.

Try to set up the nextcloud-config.

Then run the script.

P.S.
Looking at the nextcloud-config i suspect im going to have to ask about a good few of them like the certificate settings, i prob wont be sure what i should set them as in the nextcloud-config since i will already have a cert, I shall ask when i get to that point.

Thx :slight_smile:

@dan ok so i tried it. I created a new jail name (nextcloud2) setup the config, shut down the old jail and run the script.

I dont know if i did something wrong but this was what i got.

I tried to load the web UI and got the warning about this cert not being trusted, so i ticked continue anyway. (I guess i have to deal with the cert again but i thought it would use my old one from the previous instance. Cant remember what to do, was to long ago. (this is not the main problem though).

Then i got this on the web page. Just a blank page except for this text along the top.

Downgrading is not supported and is likely to cause unpredictable issues (from 30.0.2.2 to 29.0.9.2)

This was the last part of the install log

+ iocage exec nextcloud2 pw usermod www -G redis
+ iocage exec nextcloud2 chmod 777 /var/run/redis/redis.sock
+ [ true '==' true ]
+ echo 'Reinstall detected, skipping generation of new config and database'
Reinstall detected, skipping generation of new config and database
+ [ mariadb '=' mariadb ]
+ iocage exec nextcloud2 cp -f /mnt/includes/my.cnf /root/.my.cnf
+ iocage exec nextcloud2 sed -i '' 's|mypassword|4AxxxVE/xxxsZ49iyGlSlQ==|' /root/.my.cnf
+ iocage exec nextcloud2 su -m www -c 'php -f /usr/local/www/nextcloud/cron.php'
OCP\HintException: [0]: Downgrading is not supported and is likely to cause unpredictable issues (from 30.0.2.2 to 29.0.9.2) ()

Command: su -m www -c php -f /usr/local/www/nextcloud/cron.php failed!
+ iocage exec nextcloud2 crontab -u www /mnt/includes/www-crontab
+ iocage exec nextcloud2 su -m www -c 'php /usr/local/www/nextcloud/occ config:system:set maintenance_window_start --type=integer --value=5'
An unhandled exception has been thrown:
OCP\HintException: [0]: Downgrading is not supported and is likely to cause unpredictable issues (from 30.0.2.2 to 29.0.9.2) ()
Command: su -m www -c php /usr/local/www/nextcloud/occ config:system:set maintenance_window_start --type=integer --value=5 failed!
+ iocage fstab -r nextcloud2 /mnt/NAS-main/home/git/freenas-iocage-nextcloud/includes /mnt/includes nullfs rw 0 0
Successfully removed mount from nextcloud2's fstab
+ set +x
Installation complete!
Using your web browser, go to https://jackdinn.co.uk to log in
You did a reinstall, please use your old database and account credentials

You have obtained your Let's Encrypt certificate using the staging server.
This certificate will not be trusted by your browser and will cause SSL errors
when you connect.  Once you've verified that everything else is working
correctly, you should issue a trusted certificate.  To do this, run:
  iocage exec nextcloud2 /root/remove-staging.sh


Script done, output file is nextcloud.log
jack@truenas ~/git/freenas-iocage-nextcloud $ 

I have checked that the old jail is still working, and yes it is.

So what do i need to do to get nextcloud2 working ?

Edit:

Ok i figured it, i edited this version line:

NEXTCLOUD_VERSION="29" to NEXTCLOUD_VERSION="30"

It got mostly there, i had to reinstall memories and talk but other than that it seems to be ok.

1 Like

Hi @dan,

I used your script to install Nextcloud in a jail on my TrueNAS box quite a while ago. I’ve been upgrading Nextcloud using the standard upgrade function provided by Nextcloud. Everything worked well until the most recent upgrade, when I started seeing this message:

“MariaDB version 10.3 detected, this version is end-of-life and only supported as part of Ubuntu 20.04. MariaDB >=10.6 and <=11.4 is suggested for best performance, stability, and functionality with this version of Nextcloud.”

I tried upgrading MariaDB manually using the pkg command, but it didn’t work. I’ve done a lot of searching online, but I’m still stuck.

Could you please let me know how I can upgrade MariaDB?

Thanks a lot!

Hi all,

I borked my nextcloud jail by doing a pkg install (wanted to prepare for upgrading the database from mysql to postreSQL as it seems that it’s what’s expected in TrueNAS Scale and expect to upgrade there as it seems to be more convenient to host other apps compared to CORE). I did NOT touch the database, I think it’s the php dependencies or something of the sorts that brought mayhem to my original jail !

Trying to cut my losses, I’ve decided to re-run the script to get a fresh new jail (current jail exists, but is stopped). Of course this came with it’s own can of worms, but I’m now on TrueNAS CORE 13.3, got the latest version of the script (as of 16th Dec. 2024) and could run the script to create a new jail (nextcloud2) to use.

There however seems to be a problem with mysql. here is part of the logs from the script :

+ iocage exec nextcloud2 su -m www -c 'php -f /usr/local/www/nextcloud/cron.php'
Doctrine\DBAL\Exception: Failed to connect to the database: An exception occurred in the driver: SQLSTATE[HY000] [2002] No such file or directory in /usr/local/www/nextcloud/lib/private/DB/Connection.php:167
Stack trace:
#0 /usr/local/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(453): OC\DB\Connection->connect()
#1 /usr/local/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(411): Doctrine\DBAL\Connection->getDatabasePlatformVersion()
#2 /usr/local/www/nextcloud/3rdparty/doctrine/dbal/src/Connection.php(318): Doctrine\DBAL\Connection->detectDatabasePlatform()
#3 /usr/local/www/nextcloud/lib/private/DB/ConnectionAdapter.php(200): Doctrine\DBAL\Connection->getDatabasePlatform()
#4 /usr/local/www/nextcloud/lib/private/DB/QueryBuilder/QueryBuilder.php(121): OC\DB\ConnectionAdapter->getDatabasePlatform()
#5 /usr/local/www/nextcloud/lib/private/AppConfig.php(1239): OC\DB\QueryBuilder\QueryBuilder->expr()
#6 /usr/local/www/nextcloud/lib/private/AppConfig.php(264): OC\AppConfig->loadConfig(false)
#7 /usr/local/www/nextcloud/lib/private/AppConfig.php(1380): OC\AppConfig->searchValues('enabled', false, 2)
#8 /usr/local/www/nextcloud/lib/private/App/AppManager.php(131): OC\AppConfig->getValues(false, 'enabled')
#9 /usr/local/www/nextcloud/lib/private/App/AppManager.php(152): OC\App\AppManager->getInstalledAppsValues()
#10 /usr/local/www/nextcloud/lib/private/legacy/OC_App.php(234): OC\App\AppManager->getInstalledApps()
#11 /usr/local/www/nextcloud/lib/private/AppFramework/Bootstrap/Coordinator.php(90): OC_App::getEnabledApps()
#12 /usr/local/www/nextcloud/lib/base.php(716): OC\AppFramework\Bootstrap\Coordinator->runInitialRegistration()
#13 /usr/local/www/nextcloud/lib/base.php(1191): OC::init()
#14 /usr/local/www/nextcloud/cron.php(58): require_once('/usr/local/www/...')
#15 {main}
Command: su -m www -c php -f /usr/local/www/nextcloud/cron.php failed!

in addition, when I run a mysql command, I get :

mysql
ERROR 2002 (HY000): Can't connect to local server through socket '/var/run/mysql/mysql.sock' (2)

I’ve checked and /var/run/mysql/mysql.sock doesn’t exist. The whole/var/run/mysql directory seems missing.

Also maybe this info can be important :

/var/db/mysql # cat mysql_upgrade_info
10.3.34-MariaDB

What would be my next steps for trying to solve this ? Many thanks !

okay, progress. Turns out that having a my.cf in /var/db/mysql prevents the mysql-server from starting. So I’ve renamed that file and when I run service mysql-server start I have interesting things in the logs in /var/db/mysql/mysqld.err :

2024-12-27  9:55:57 0 [Note] Starting MariaDB 10.6.19-MariaDB source revision 8f020508c87461bbeee551c3001acac56d506ae7 server_uid hxpB9W6mHy0uZ7C1wq+bKyTlW6Q= as process 18622
2024-12-27  9:55:57 0 [Warning] You need to use --log-bin to make --binlog-format work.
2024-12-27  9:55:57 0 [Note] InnoDB: Compressed tables use zlib 1.3.1
2024-12-27  9:55:57 0 [Note] InnoDB: Number of pools: 1
2024-12-27  9:55:57 0 [Note] InnoDB: Using crc32 + pclmulqdq instructions
2024-12-27  9:55:57 0 [Note] InnoDB: Initializing buffer pool, total size = 134217728, chunk size = 134217728
2024-12-27  9:55:57 0 [Note] InnoDB: Completed initialization of buffer pool
2024-12-27  9:55:57 0 [ERROR] InnoDB: Upgrade after a crash is not supported. The redo log was created with MariaDB 10.3.34. You must start up and shut down MariaDB 10.4 or earlier on the data directory.
2024-12-27  9:55:57 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2024-12-27  9:55:57 0 [Note] InnoDB: Starting shutdown...
2024-12-27  9:55:58 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2024-12-27  9:55:58 0 [Note] Plugin 'FEEDBACK' is disabled.
2024-12-27  9:55:58 0 [ERROR] Unknown/unsupported storage engine: InnoDB
2024-12-27  9:55:58 0 [ERROR] Aborting

The key part being needing to use MariaDB 10.4 and not 10.6. I thought I could simply edit the script to use package mariadb104-server rather than mariadb106-server, but that doesn’t seem feasable. even according to FreshPorts -- databases/mariadb104-server: Multithreaded SQL database (server) the packages don’t seem available for AMD64.

so what should I do ? I feel that my next steps would be to mount the db dataset on a SMB and access it from an external linux machine, install mariaDB 10.4 on the linux machine, and do the upgrading from there.