Tutorial - How to upgrade Nextcloud 10 (Freenas 11.1) to Nextcloud 15 (FreeNAS-11.2-RELEASE) with databse (with versions and deleted files)

petoz

Dabbler
Joined
Dec 7, 2017
Messages
18
First of all create new nextcloud jail in FreeNAS-11.2-RELEASE
1545593502631.png


- Then login to FreeNAS, list your old warden jails and run console on it
root@freenas:~ # warden list ID AUTOSTART STATUS TYPE --------------------------------------------------------------------------- nextcloud_1 Enabled Running pluginjail plexmediaserver_1 Enabled Running pluginjail root@freenas:~ # warden chroot nextcloud_1 Started shell session on nextcloud_1. Type exit when finished.

Run maintenance mode on old running nextcloud
# cd /usr/pbi/nextcloud-amd64/www/nextcloud/ # su -m www % ../../bin/php occ maintenance:mode --on The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php Maintenance mode enabled

Backup old nextcloud database
# cat config/config.php |grep dbuser 'dbuser' => '*****', # cat config/config.php | grep dbpass 'dbpassword' => '*****', # ../../bin/mysqldump --single-transaction -u ***** --password=***** nextcloud > /media/nextcloud-sqlbkp_`date +"%Y%m%d"`.bak

Backup old nextcloud config file
cp /mnt/nas4/jails/nextcloud_1/usr/pbi/nextcloud-amd64/www/nextcloud/config/config.php /mnt/iocage/jails/nextcloud/root/media/

Exit form old wareden nextcloud jail
Move mysql backup and config.php to newly created nextcloud iocage jail
root@freenas:~ # mv /mnt/nas4/jails/nextcloud_1/media/nextcloud-sqlbkp_20181223.bak /mnt/iocage/jails/nextcloud/root/media/ root@freenas:~ # mv /mnt/nas4/jails/nextcloud_1/media/config.php /mnt/iocage/jails/nextcloud/root/media/

Download Nextcloud 11 (update is allowed only by one major version)
root@freenas:~ # wget https://download.nextcloud.com/server/releases/nextcloud-11.0.8.tar.bz2

Move file to new jail
root@freenas:~ # mv nextcloud-11.0.8.tar.bz2 /mnt/iocage/jails/nextcloud/root/media/

List jails and login to console
root@freenas:~ # iocage list +-----+--------------+-------+--------------+------+ | JID | NAME | STATE | RELEASE | IP4 | +=====+==============+=======+==============+======+ | 6 | FreeBSDJail | up | 11.2-RELEASE | DHCP | +-----+--------------+-------+--------------+------+ | 3 | emby | up | 11.2-RELEASE | DHCP | +-----+--------------+-------+--------------+------+ | 37 | nextcloud | up | 11.2-RELEASE | DHCP | +-----+--------------+-------+--------------+------+ root@freenas:~ # iocage console nextcloud

cd to /usr/local/www directory and remove nexctloud directory
root@nextcloud:~ # cd /usr/local/www/ root@nextcloud:/usr/local/www # rm -r nextcloud root@nextcloud:/usr/local/www # tar xzf /media/nextcloud-11.0.8.tar.bz2

Exit from iocage nextcloud jail
Copy files from old nextcloud to new
root@freenas:~ # mkdir /mnt/iocage/jails/nextcloud/root/usr/local/www/nextcloud/data root@freenas:~ # cp -r /mnt/nas4/jails/nextcloud_1/media/ /mnt/iocage/jails/nextcloud/root/usr/local/www/nextcloud/data/

Go back to new iocage, create database and restore
root@freenas:~ # iocage console nextcloud root@nextcloud:~ # cat dbpassword ***** root@nextcloud:~ # mysql -u dbadmin --password=***** -e "CREATE DATABASE nextcloud" Warning: Using a password on the command line interface can be insecure. root@nextcloud:~ # mysql -u dbadmin --password=***** nextcloud < /media/nextcloud-sqlbkp_20181223.bak Warning: Using a password on the command line interface can be insecure.

Change owner and group of nextcloud directory
root@nextcloud:~ # cd /usr/local/www/ root@nextcloud:/usr/local/www # chown -R www nextcloud root@nextcloud:/usr/local/www # chgrp -R www nextcloud

Copy and change config.php data directory, dbuser and dbpassword (password is in root/dbpassword file)
root@nextcloud:/usr/local/www # cp /media/config.php nextcloud/config/ 'datadirectory' => '/usr/local/www/nextcloud/data', 'dbuser' => 'dbadmin', 'dbpassword' => '*****',

Run upgrade of database
root@nextcloud:/usr/local/www # /root/occ.sh upgrade

Turn of maintenance mode
root@nextcloud:/usr/local/www # /root/occ.sh maintenance:mode --off

Test from web browser sucessfull upgrade
Then go to admin section of web browser, change Cron to AJAX and click "Open updater"
1545602290498.png


Then click "Start update"
1545602441012.png


Click "No (for usage for web based updater)"
1545602863848.png


Go to end and click "Start update"
1545603010574.png


Repeat these steps until version 14 or change train to "beta" and can go to version 15.

Hope will help someone.
 

Attachments

  • 1545602175215.png
    1545602175215.png
    60.7 KB · Views: 533
  • 1545602250506.png
    1545602250506.png
    84.1 KB · Views: 401
  • 1545602405873.png
    1545602405873.png
    59.9 KB · Views: 529
  • 1545602974847.png
    1545602974847.png
    804.1 KB · Views: 473

ShutUpFry

Dabbler
Joined
May 20, 2018
Messages
15
When I get to the step that says "Test from web browser successful upgrade" I get a page that says "Welcome to nginx!". Any suggestions?
 

petoz

Dabbler
Joined
Dec 7, 2017
Messages
18
When I get to the step that says "Test from web browser successful upgrade" I get a page that says "Welcome to nginx!". Any suggestions?
Did you make jail from template "Nextcloud" or try to restart service nginx and php-fpm?
service php-fpm restart service nginx restart
 

ShutUpFry

Dabbler
Joined
May 20, 2018
Messages
15
Did you make jail from template "Nextcloud" or try to restart service nginx and php-fpm?
service php-fpm restart service nginx restart

Yeah, and I tried restarting and reinstalling the plugin several times. It appears this was a problem in some of the beta releases and it seems to still exist, but is less likely to happen. Eventually one of the reinstalls worked and I went from there. Your guide was very helpful. Thanks!
 

Krowvin

Explorer
Joined
Jul 24, 2014
Messages
60
I wasn't sure where to post this, so i'll post in this thread. (Someone might Google to it)

I was having problems with my version of php-gc in the warden jails.


I lost count of how many posts I read to cobble together a working solution.
There were two primary ones (see end of post)

I did not try the jail migration script, as I wanted a clean jail.
I had so many old files in the previous jail, and I read somewhere the jail would need to be upgraded or something later on. So I decided to go ahead and just create a fresh iocage jail.

Note: I tested this on one of my unimportant jails first
(still have both of the old jails in the old web ui in case something goes horribly wrong)
Here are some rough steps as to what I did to migrate my Nextcloud 14.0.3.0 to 15.0.4.0 on a new iocage jail.

1. create a backup of the four primary items for nextcloud restoration
read:
https://docs.nextcloud.com/server/12/admin_manual/maintenance/backup.html

and

https://docs.nextcloud.com/server/12/admin_manual/maintenance/restore.html

The configuration directory
The data directory
The database
The theme directory

The theme directory and configuration directory are both in the web root
probably /usr/local/www/nextcloud

Run this to back it up
Code:
cd /usr/local/www/nextcloud
tar -zcvf nextcloud_backup.tgz .

Note: you must be in the directory you want to zip

Copy the backup OUTSIDE of your jail
I exited to jail to the root user of freenas itself.
Then ran
Code:
cp -r /mnt/[pool]/jails/nextcloud/usr/local/www/nextcloud/nextcloud_backup.tgz /mnt/[pool]/[some_dataset_outside_jail]


If you have your data directory mounted you will not need to do this.

I also made a copy of my NGINX configuration file located
/usr/local/etc/nginx/nginx.conf
and moved it to the same dataset I put my web files in

Lastly, you'll want to backup the database. If you forgot your database credentials you can find them in
Code:
nano /usr/local/www/nextcloud/config/config.php


To backup the database run, login to the old jail with the database running and
Code:
cd /tmp
mysqldump --single-transaction -u <username_from_config_file> -p <db_name_from_config_file> > nextcloud-sql.bak

Exit the jail and copy this file to the dataset outside the jail i.e.
Code:
cp -r /mnt/[pool]/jails/nextcloud/tmp/nextcloud-sql.bak /mnt/[pool]/[some_dataset_outside_jail]


2. Now that you have everything backed up you can create your new jail.
You'll have to login to the new UI for this. I am running freenas on the latest STABLE build. That's 11.1 U7 as of writing this. (11.2 is still beta)

To login to the new web interface type
http://<freenasip>/ui, so http://192.168.69.69/ui

For some reason my settings defaulted my iocage to a different dataset than my current jails. (I wanted them on the SSD)
I had to move the jail dataset, destroy the one it made elsewhere, then slammed the keys around until I was able to get it to recreate the folder structure in the new place. (I can search my history if someone gets stuck on this)

Clicked jail in the new ui, moused over the 'hamburger icon' and click the plus + (add jail).
Here are the settings I used, everything else was blank
jails name:nextcloud
release:11.2-RELEASE (fun fact, you can't start the jail from iocage in the console if you chose a higher version in the gui than your freenas runs. You have to manage it through the new GUI[start/stop] )
ipv4addr: igb0|192.168.69.70/24 super important here that you pick your interface, you can type ifconfig -a if you aren't sure what it is. My nic was igb0 and I have a subnet of 24

Click jail properties
check "allow_raw_sockets"

then click save

Other people have done this in the command line.

3. Add storage to your jails -
something like - from another post
Code:
iocage fstab -a nextcloud"/mnt/tank/source/folder /destination/folder/in/jail nullfs rw 0 0"


4. I then started the jail from the gui.

5. The rest was a matter of setting up the jail exactly how I had it before (following the same guide) and mixing a few new commands in for the newer version of php, i.e. replace all the php commands with php70 to php72

Here are the guides I smashed together to get the rest of it to work
https://forums.freenas.org/index.ph...3-on-freenas-11-with-all-checks-passed.58634/

https://forums.freenas.org/index.php?threads/how-to-owncloud-using-nginx-php-fpm-and-mysql.17786/
Thank you Dureal99d and Joshua

I now have A+ on my Nextcloud server :D
 
Top