Resource icon

Scripted installation of Nextcloud 28 in iocage jail 2018-03-23

mapcevn

Dabbler
Joined
Jul 10, 2019
Messages
40
Hi Danb35,
My Nextcloud installed with your script has been running well for more than three years. Thank you again for this amazing script!
During the past three years, few minor issues happened each time I upgrade the nextcloud to new version, but I managed to fix them. However, this time, my Nextcloud upgraded to 25.0.3 encountered a warning:

"You are currently running PHP 7.4.20. Upgrade your PHP version to take advantage of performance and security updates provided by the PHP Group ↗ as soon as your distribution supports it."

I have no idea how to upgrade the PHP to address this warning within the iocage.

Could you please let me know which command I should run to upgrade the PHP to the new version to get rid of this warning?
Thanks
 

victort

Guru
Joined
Dec 31, 2021
Messages
973
Hi Danb35,
My Nextcloud installed with your script has been running well for more than three years. Thank you again for this amazing script!
During the past three years, few minor issues happened each time I upgrade the nextcloud to new version, but I managed to fix them. However, this time, my Nextcloud upgraded to 25.0.3 encountered a warning:

"You are currently running PHP 7.4.20. Upgrade your PHP version to take advantage of performance and security updates provided by the PHP Group ↗ as soon as your distribution supports it."

I have no idea how to upgrade the PHP to address this warning within the iocage.

Could you please let me know which command I should run to upgrade the PHP to the new version to get rid of this warning?
Thanks
There are a few ways of going about this.

1. Removing php74 packages and installing php80 packages from the shell.

2. Deleting jail and reinstalling from the script. This will keep your data, as it’s mounted outside the jail, and install php80 from the script. (The script has been updated to use php80)

Personally I would opt for #2, because it’s simple and from my experience works.

EDIT: Stop your jail and rename it. Run the script using the same info as when you started. This will use the same mount points and act as a reinstall.

Once you confirm everything works, you can delete your old jail.

If it doesn’t work, you can simply rename your old jail back to where it was, and continue where you left off. (I’m fairly certain it will work as I did this recently on another jail)

Mind you for me it wasn’t an upgrade from php74 to php80, but the reinstall should still work nonetheless.
 

GBillR

Contributor
Joined
Jun 12, 2016
Messages
189
There are a few ways of going about this.

1. Removing php74 packages and installing php80 packages from the shell.
I was able to get this done this way. Mind you, I did not use the script to install nextcloud, but I do run it in a jail, and was receiving the same warnings. I believe that Danb35's script accomplishes the same end result, so I would think you should be okay.

The nexcloud jail creation method that I used was the installation method here. If you look through the comments there, you will find some useful information as well regarding the php upgrade. I was not aware until recently, but this is also saved in the resource section here.

It did make me nervous, and I also upgraded the jail to the latest BSD release as well. I was pleasantly surprised that my upgrade and php update worked without breaking my installation. YMMV.

EDIT: Be sure that you verify the php version is compatible with your version of nextcloud here. Be careful... the newest is not listed as compatible.
 

victort

Guru
Joined
Dec 31, 2021
Messages
973
I was able to get this done this way. Mind you, I did not use the script to install nextcloud, but I do run it in a jail, and was receiving the same warnings. I believe that Danb35's script accomplishes the same end result, so I would think you should be okay.
It does, but in a simpler, user friendly way without having to manually do anything. It also uses caddy server, which allows for automatic cert management with little to no user interaction.
EDIT: Be sure that you verify the php version is compatible with your version of nextcloud here. Be careful... the newest is not listed as compatible.
I’m running the latest Nextcloud with php80 with 0 issues.
 

GBillR

Contributor
Joined
Jun 12, 2016
Messages
189
It does, but in a simpler, user friendly way without having to manually do anything. It also uses caddy server, which allows for automatic cert management with little to no user interaction.
I do not disagree. If I had to do it again, I would probably use the script... but, I did learn a lot by doing it manually. I also learned how to setup a reverse proxy using nginx.

I’m running the latest Nextcloud with php80 with 0 issues.
I installed 8.1 and have no issues with that version. However, I believe 8.2 is the most recent release. 8.2 is not listed in the nextcloud docs yet... even though I imagine it would likely work okay.
 

mapcevn

Dabbler
Joined
Jul 10, 2019
Messages
40
Thank you victort and GBillR. I ended up choosing the first way mentioned in victort's post as my cloud is live, and I did not want to mess up things which have been in use.

I used some commands inspired by this post https://www.truenas.com/community/threads/pkg-upgrade-within-iocage-jail.75697/#post-526262

Basically, I did the followings:
1. List all current php modules:
pkg info -x php

2. Then, I deleted the old php with this command:
pkg delete php74

3. Then, I compiled the outputs at step 1 into a single command:
pkg install php80 php80-bcmath php80-bz2 php80-ctype php80-curl php80-dom php80-exif php80-fileinfo php80-filter php80-ftp php80-gd php80-gmp php80-iconv php80-imap php80-intl php80-ldap php80-mbstring php80-mysqli php80-opcache php80-pcntl php80-pdo php80-pdo_mysql php80-pecl-APCu php80-pecl-imagick php80-pecl-memcache php80-pecl-redis php80-pecl-smbclient php80-posix php80-session php80-simplexml php80-xml php80-xmlreader php80-xmlwriter php80-xsl php80-zip php80-zlib

4. Then, restart php
service php-fpm restart

My nextcloud seems to be working now, that PHP warning message has gone!!!
 

ccman32

Dabbler
Joined
Aug 16, 2022
Messages
17
Hi everyone,

first of all, thank you @danb35 for this useful script! I just used it to set up my Nextcloud and so far it is working perfectly fine.
I am now just trying to figure out how to include the Nextcloud into my existing backups.
Can I simply zfs send/recv the config, db, files and themes datasets to my backup pool and call it a day, or is there more to it?
I was also looking into Nextcloud's own backup app for automatically creating backups and then storing those in a separate dataset which I can then send to my backup pool, but I don't know what is the better solution here.
Please let me know if anyone here has some tips or general advice regarding this.

Thanks a lot in advance!
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Can I simply zfs send/recv the config, db, files and themes datasets to my backup pool and call it a day, or is there more to it?
One thing I'd suggest in addition to this--which would need to be run on a schedule in the Nextcloud jail--would be to run mysqldump before the backup takes place. That will give you a consistent database, while backing up the "live" database files might not. Otherwise this should be a good plan.
 

ccman32

Dabbler
Joined
Aug 16, 2022
Messages
17
One thing I'd suggest in addition to this--which would need to be run on a schedule in the Nextcloud jail--would be to run mysqldump before the backup takes place. That will give you a consistent database, while backing up the "live" database files might not. Otherwise this should be a good plan.
Thanks a lot for the quick response! I don't quite understand yet how exactly that would work. At the moment, I am manually initiating my backup process after the backup pool is imported (it is located on an external HDD and not on another server). Therefore, my Nextcloud jail isn't really aware of when exactly the backup takes place. How can I get around this problem, or have I misunderstood your suggestion?
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
Therefore, my Nextcloud jail isn't really aware of when exactly the backup takes place.
That would make it trickier to do as I suggested. But is your backup process scripted? If so, you can add iocage exec nextcloud mysqldump <parameters> to that script--and maybe even remove the dump file after the script had completed.
 

ccman32

Dabbler
Joined
Aug 16, 2022
Messages
17
That would make it trickier to do as I suggested. But is your backup process scripted? If so, you can add iocage exec nextcloud mysqldump <parameters> to that script--and maybe even remove the dump file after the script had completed.
Yes, it is scripted so I could try adding what you suggested. However, the second backup method which I use is to simply copy my storage dataset data over to my second NAS (WD MyCloud) via rsync. This is not scripted and instead just uses a normal rsync task which is configured via the TrueNAS Core Web UI. Ideally, I'd like to have a Nextcloud backup stored there, too. I don't see how that would be possible with this approach.

Another approach I started to test is using the Backup app in Nextcloud to regularly create backups and then store those on a new dataset on my main pool via a SMB share which Nextcloud can then use to access the dataset. The advantage here would be that I don't have to take care of manually enabling maintenance mode, creating sql dumps etc. and instead I can just zfs send/recv the new dataset to my backup pool and also copy it to my second NAS via rsync.

Would this make any sense, or am I overcomplicating things and there is a better solution for my scenario?
 
Last edited:

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
This is not scripted and instead just uses a normal rsync task which is configured via the TrueNAS Core Web UI. Ideally, I'd like to have a Nextcloud backup stored there, too. I don't see how that would be possible with this approach.
Set up a cron job that does the mysqldump just before the rsync task is scheduled to run.
 

ccman32

Dabbler
Joined
Aug 16, 2022
Messages
17
Set up a cron job that does the mysqldump just before the rsync task is scheduled to run.
But is this something that is only expected to take a few seconds or so to run, or will it potentially take longer and longer the more data is stored in the Nextcloud over time? I am asking this because in the latter case, I'm not sure how to feel about loosely coupling the mysqldump and the rsync task like this since I cannot ensure that the dump is complete before the backup is performed.
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Probably a minute or two. The Nextcloud database is not growing to very large sizes in my experience.
In the worst case you will have the same binary copy backup like you have now. In the best case you will have a consistent database dump, too.
 

ccman32

Dabbler
Joined
Aug 16, 2022
Messages
17
Probably a minute or two. The Nextcloud database is not growing to very large sizes in my experience.
In the worst case you will have the same binary copy backup like you have now. In the best case you will have a consistent database dump, too.

Alright. Wouldn't it be easier then to simply have a cron job or something on the Nextcloud jail that runs like once a day or so and either creates a new or overwrites the current sql dump with a new one? Then I could simply backup the dataset whenever I want and always have a somewhat recent db dump included in the backup. Or is there anything wrong or problematic about this approach?
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,776
Sounds good. In the case of Nextcloud diverging database and filesystem states are not really an issue, because after desaster recovery you can always perform php occ file:scan --all
 

ccman32

Dabbler
Joined
Aug 16, 2022
Messages
17
Sounds good. In the case of Nextcloud diverging database and filesystem states are not really an issue, because after desaster recovery you can always perform php occ file:scan --all
Alright. Thanks a lot for your help!
 

ccman32

Dabbler
Joined
Aug 16, 2022
Messages
17
Hey there, I currently still have one problem which I could not find a solution for. After manually replacing the ssl certificate for the caddy webserver hosting Nextcloud, it is still serving the old certificate. Executing service caddy reload does not seem to solve this. Do I have to completely stop and restart caddy, or is there a better way to make it aware that the certificate has changed?
 

danb35

Hall of Famer
Joined
Aug 16, 2011
Messages
15,504
After manually replacing the ssl certificate for the caddy webserver hosting Nextcloud, it is still serving the old certificate.
How did you do this? And why?
 

ccman32

Dabbler
Joined
Aug 16, 2022
Messages
17
How did you do this? And why?
Just for testing. I am using a script similar to this to automatically renew the certificate and noticed that the old certificate was still served by Nextcloud after it was already updated by the script.
 
Top