Cloning NextCloud App from one Truenas Server to another Truenas Server

I wanted to share my experience in setting up an identical clone of the NextCloud App on a secondary TrueNas Scale server.

I found this to be especially useful when you are running NextCloud in a production environment, and you want to test an update before you roll it out to production.

Step 1.
Set up a secondary TrueNas Server and the appropriate application datasets.
Make sure the name of your datasets is exactly like the primary source.

Step 2.
Install a blank deployment of NextCloud on your new TrueNas Server
Configure each option exactly the same as the first server

  • Same passwords for DB and Redis, etc…
  • Also tick the Automatic permissions at the bottom of the configuration

Hint: Choose a different name for the Server name with the overwitehost option.

Point in your DNS Server the new name to the IP of your secondary TrueNas Server.

Step 3.
Set up 3 rsnyc task for each of the main folders appdata, postgresdb and userdata.

Make sure you are synchronizing into the root of the remote server NextCloud Folder not in the individual folders.

Choose the sync timing you want.

Step 4.
Finish the initial sync

Step 5.
Correct permissions.
On the destination server run following 4 commands one after another: (Execute as root / sudo)
chown -R www-data:www-data /mnt/%YourPoolName%/NextCloud_app/

find /mnt/%YourPoolName%/NextCloud_app/ -type d -exec chmod 750 {} ;

find /mnt/%YourPoolName%/NextCloud_app/ -type f -exec chmod 640 {} ;

chown -R 999:999 /mnt/%YourPoolName%/NextCloud_app/postgresdb/

Hint: This might take some time depending on the size of your data.

Step 6.
Now you can go ahead and start the App and you will be able to log in to the web interface with the admin user and PW of your primary instance.
All data will be visible as it was at the time of the Rsync job.

Quirks:
Since the rsync will mess with the permissions each time it runs it is advisable to set up a scheduled task that runs each time after the sync and repeats Step 5.
For me since im using the secondary instance only for update validation I run Step 5. each timer by hand.

Hope this helps. I did google my fingers round till I figured out how to set this up.

Can’t add pictures with my instructiions. Sad…