migrate NC from one to another FreeNAS server

ddaenen1

Patron
Joined
Nov 25, 2019
Messages
318
I am running NC on FreeNAS 11.3 U5 on a single Supermicro server but would want to transfer it to another Supermicro FreeNAS 11.3 U5 server that also hosts my Plex as it has better specs and more storage. Is there an easy way to migrate without having to install the plugin from scratch, setting up the accounts and manually transfer all the data?
 

ddaenen1

Patron
Joined
Nov 25, 2019
Messages
318
Considering the huge response, i guess it will become a good old "set up from scratch and copy files" migration. Fun fun fun :oops:
 

ddaenen1

Patron
Joined
Nov 25, 2019
Messages
318
Well, i need help. I have a couple of challenges. When last time my Nextcloud went down it was because the thumbdrive that Freenas was installed on died. I hooked up an external USB HDD, did a new FreeNAS install, located the nextcloud user files, copied them to my other FreeNAS server fileshare, reinstalled the nextcloud plugin, recreated the users and uploaded the content of each user back to their respective cloud from inside nextcloud. Worked perfect. I am sensitive about NC because all iphones in the house sync their media to the cloud and i have also started moving more and more personal files to it because of the easy access from everywhere and the stability.

I have finally decided to move Nextcloud to my other TrueNAS server because it runs on 2 SSD drives in Zmirror connected to an MD1000 running 15 2Tb SAS drives in RAIDZ2 with only Plex installed so there is plenty of storage space and much more OS stability due to the 2 SSD's and data safety due to the RAIDZ2 and the ease of exchanging a faulty HDD, if needed. The system is dated but doing its job and you can buy 2Tb LFF SAS drives for cheap so i always have a couple spare in my stash.

As nobody came with an easier approach as i used last time, i want to use the exact same process as described above. This time, i seem to have issues getting access to the data directory of nextcloud when i set up an SMB share. Didn't have any issues with that last time. In fact, fiddling around with the access rights of the share, made my NC go offline because somehow, i removed all access rights to the Data folder which caused NC to fail. An easy fix but still, my heart did skip a beat.

Any ideas how i can approach this? Or still, if there are easier ways to transfer NC from one FreeNAS server to another one, i am eager to learn about it.

Thoughts?
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,740
There are three things you need to transfer:
  • data
  • database
  • configuration
I have done that multiple times. Dead easy. For me :wink: But I always do things like this on the shell. Why would one go via a Samba share that potentially messes with access rights and "stuff" when there is ssh/scp/rsync - or zfs send/receive if your data is on a separate dataset.

The database can be exported with mysqldump and re-imported with the mysql command.

Configuration - open two editors (via ssh directly on the system, of course - don't edit them on Windows!)

All of this can be quite intimidating at first but why don't you start with a clean installation, get Nextcloud up and running on the target system (empty, of course) and come back with specific questions about the individual steps?
 

Heracles

Wizard
Joined
Feb 2, 2018
Messages
1,401
Hey @ddaenen1,

Jails are not very flexible. I do not use them for that reason. Here, I do run Nextcloud but from Docker containers. I can tell you what it takes to do it in the containers world.

The Nextcloud container itself is built using 5 volumes :
root = /var/www/html
config = /var/www/html/config
apps = /var/www/html/custom_apps
themes = /var/www/html/themes
data = /var/www/html/data

"Data" is an NFS share mounted by the docker host from my FreeNAS. It is then re-mapped inside the container.
The others are regular Docker volumes.

I also have a MariaDB container.

To restore my Nextcloud to another server, i need to :
--Recover the content of the 4 docker volumes that have been backed up as tarballs and re-create these volumes
--Deploy a new database container and restore the sqldump I took before
--Re-map the NFS share to the new docker host
--Deploy the Nextcloud container, mounting the 5 volumes in it and pointing it to the new database

And here we go : a brand new Nextcloud server running the previous config and serving the same data.
 

ddaenen1

Patron
Joined
Nov 25, 2019
Messages
318
All of this can be quite intimidating at first but why don't you start with a clean installation, get Nextcloud up and running on the target system (empty, of course) and come back with specific questions about the individual steps?

OK, i will make a fresh install on the other TrueNAS server over the weekend and we will take it from there.
 

ddaenen1

Patron
Joined
Nov 25, 2019
Messages
318
OK, i will make a fresh install on the other TrueNAS server over the weekend and we will take it from there.

So, 2 things happened today.

1. I managed to backup my current NC data through an SMB share without breaking anything. :smile:
2. I did a fresh Nextcloud plugin install on my other TrueNAS server which went flawless. @Patrick M. Hausen what's next?
 

Patrick M. Hausen

Hall of Famer
Joined
Nov 25, 2013
Messages
7,740
Check where the data directory is configured in your new installation. Copy the data there deleting everything already present. Make sure the owner and group match the runtime user of your Nextcloud - probably "www:www".

Dump the database of your old installation:
mysqldump -u[db user] -p[db password] --opt --quote-names --hex-blob [db name] | gzip -c > /tmp/nc-db.sql.gz
Database name and credentials will be in your NC configuration file in clear text. Make sure not to put a space between -p and the password.

Copy that dump file to the new installation, import like this:
gzip -dc /tmp/nc-db.sql.gz | mysql -u[db user] -p[db password] [db name]
Possibly the name and probably the credentials will differ from the source system - check in the config.

If that works without error your Nextcloud should already be able to do "something", probably complain about domain name mismatches and some such, but generally it should work. You need to iteratively resolve all these minor things. Hostname, Letsencrypt, ...

Just come back when you are unsure about anything.
 

ddaenen1

Patron
Joined
Nov 25, 2019
Messages
318
Well, it is done. After i dumped the db, i had a though time to get the file from our server to the other one, not being a FreeBSD subject matter expert. Eventually, i did it the way i did it last time. I recreated the users in new installation, uploaded all the files via NC and eventually, made the changes to config.php for my FQDN and certs and that is that. Working flawless.

I regret only one thing, i really wanted the NC data in a different pool than the jails but i couldn't figure that out after the installation. Is it possible to relocate the data to another pool after installation of the plugin?
 
Top