TrueCharts to TrueNAS – App migration
Due to TrueNAS SCALE dropping support for Kubernetes in favor of Docker, I had to decide what to do with my TrueCharts Apps:
- Option 1: Keep running TrueCharts Apps, which would entail …
- running a Talos Linux VM on TrueNAS Scale
- migrate the TrueCharts Apps using the ‘clustertool’
- manage a Kubernetes cluster (Talos Linux)
- Option 2: Migrate TrueCharts Apps to TrueNAS native Apps, which would entail …
- migrating apps (with the next TrueNAS Scale upgrade, all native Apps will be automatically be migrated to it’s Docker counterpart.)
I went with Option 2.
The following is the process of me migrating TrueCharts Nextcloud to native TrueNAS Scale Nextcloud.
Nextcloud is reachable from outside my LAN via a domain name (external DNS: CloudFlare).
TrueNAS Scale verison: Dragonfish-24.04.2
Storage configuration:
- 2 x SSDs (mirrored) for apps
- 5 x HDDs (RAIDZ1) for data
NextCloud
The first thing I wanted to test was setting up the TrueNAS Scale native Nextcloud App, with Collabora and external access.
I started off by testing this how-to (https://forums.truenas.com/t/a-full-guide-for-installing-nextcloud-on-truenas-scale-with-collabora-integration-and-outside-access-through-nginx-proxy-manager/5874) on a spare TrueNAS Scale system. When I was happy with the test results, I proceeded to perform the setup on my productive system, where my TrueCharts Apps were installed and running.
Storage setup
As was suggested in the above-linked how-to, I created separate datasets for each configurable storage entry in the TrueNAS Nextcloud install.
Directly under the TrueNAS storage pool, I created a ‘nextcloud’ dataset with
- Dataset Preset = Apps
- ACL
- User ‘www-data’ given ‘Full Control’
- Group ‘www-data’ given ‘Full Control’
Inside of the ‘nextcloud’ dataset I then created four child datasets (all with the same ‘Dataset Preset’ and ACLs as the ‘nextcloud’ dataset):
- app_data
- user_data
- postgres_data
- postgres_backup
Installation (Nextcloud)
For the initial installation, I only altered the following fields:
- Application name = ncloud (I had to use this name because ‘nextcloud‘ was already in use by the TrueCharts App)
- Admin User = admin
- Admin Password = ***
- Additional Environment Variables (Add)
- Name: OVERWRITEHOST
- Value: nextcloud.mydomain.com
- Commands → Add → ffmpeg + smbclient
- Storage Configuration – set ‘Type’ to ‘Host Path’ and then select the corresponding dataset in the ‘Host Path’ field for all four:
- Nextcloud AppData Storage (HTML, Custom Themes, Apps, etc.) -> app_data
- Nextcloud User Data Storage -> user_data
- Nextcloud Postgres Data Storage -> postgres_data
- Nextcloud Postgres Backup Storage -> postgres_backup
That’s all.
Click ‘Install’ and wait a few minutes for the App’s status to show ‘Running’.
Domain Setup
First thing is to install Nginx Proxy Manager. I didn’t change any of the default config options.
Once it was installed, I could access it at http://server-IP-address:30020.
Port Forwarding
On my router/modem I needed to forward port 443 to port 30022 on the server IP address where Nextcloud is installed.
SSL Certificate (CloudFlare)
In Nginx Proxy Manager click on ‘SSL Certificates’ and then on the ‘Add SSL Certificate’ button on the right. Click on the ‘Let’s Encrypt’ option from the drop-down menu.
- Domain Names: mydomain.com *.mydomain.com
- Use a DNS Challenge → enable
- DNS Provider: Cloudflare
- Credentials File Content:
- # Cloudflare API token
dns_cloudflare_api_token=*enter your Cloudflare API token here*
- # Cloudflare API token
- Agree to the TOS
- Click ‘Save’ and give it a few seconds to complete the process.
Proxy Host
Click on ‘Hosts’ → ‘Proxy Hosts’ → ‘Add Proxy Host’ (button on the right).
Under the ‘Details’ tab:
- Domain Names: nextcloud.mydomain.com
- Scheme: http
- Forward Hostname/IP: The IP address of your server-IP
- Forward Port: 9001
- Block Common Exploits: enable
Under the ‘SSL’ tab:
- SSL Certificate: select the certificate made in previous step
- Force SSL: enabled
- HTTP/2 Support: enabled
- HSTS Enabled: enabled
Click ‘Save’.
At this point you should be able to access your Nextcloud instance via https://nextcloud.mydomain.com.
Installation (Collabora)
- Username for WebUI: *setausername*
- Password for WebUI: *setapassword*
- Server Name: collab.mydomain.com:443
NPM Proxy Host
Click on ‘Hosts’ → ‘Proxy Hosts’ → ‘Add Proxy Host’ (button on the right).
Under the ‘Details’ tab:
- Domain Names: collab.mydomain.com
- Scheme: http
- Forward Hostname / IP: The IP address of your server-IP
- Forward Port: 9980
- Websockets Support: enable
Under the ‘SSL’ tab:
- SSL Certificate: select the certificate made previously for mydomain.com
- Force SSL: enabled
- HTTP/2 Support: enabled
- HSTS Enabled: enabled
Click ‘Save’.
Nextcloud Office Setup
- Login to Nextcloud as the admin user
- Click on the profile icon (top-right corner) → Apps
- On the left menu bar click on ‘Office & text’ → Download and enable the ‘Nextcloud Office’ app
- Click on the profile icon (top-right corner) → Administration settings
- On the left menu bar click on ‘Office’
- Select ‘Use your own server’
- URL (and Port) of Collabora Online-server: https://collab.mydomain.com:443
- Click ‘Save’
Nextcloud User Data
I placed both instances of Nextcloud in maintenance mode.
In the TrueCharts app config for NextCloud, I had the ‘User Data Storage’ variable set to ‘Host Path’ and pointing to a dataset on my TrueNAS storage pool (not an “App” pool/dataset), so I could easily access all the data.
So all I did here was rsync the user folders (one at a time) from the old location to the new location with:
rsync rltv /path-to-old-user-data/userfolder /mnt/*truenas-pool*/nextcloud/user_data/
Nextcloud Database
Install PGAdmin (TrueNAS)
In my case, I wanted to also switch over from using the PGAdmin App from TrueCharts to that of TrueNAS, so I went ahead and installed the PGAdmin App from TrueNAS with all the default installation options (other than ‘Admin Email’ and ‘Admin Password’).
Once installation was complete, I could access PGAdmin’s frontend via http://server-IP-address:30056.
When attempting to login, I would sometimes get an error like ‘CSRF tokens do not match’, which I think was due to two PGAdmin instances running on the same server, or in the same browser from the same server. Not entirely sure. But after I stopped the TrueCharts PGAdmin instance, the error went away. The other workaround was to open the TrueNAS PGAdmin in an incognito browser window.
Connect Databases to PGAdmin
I connected the databases of both Nextcloud instances into the TrueNAS PGAdmin app.
I copied the database details of the TrueCharts Nextcloud instance from the TrueCharts PGAdmin database connection setup. The most important details were (in my case):
- Host name/address: nextcloud-cnpg-main-rw.ix-nextcloud.svc.cluster.local
- Username: nextcloud
- Password: *mynextclouddatabasepassword* (password located in the NextCloud config.php)
Then I connected the TrueNAS Nextcloud database. The database details were displayed in TrueNAS → Apps → click on the TrueNAS Nextcloud app → Notes (info box to the right) → Database → Database Details.
Prepare for Database Restoration
The next task was to delete the existing database for the TrueNAS Nextcloud instance, and create an empty database in it’s place – this is what is recommended by Nextcloud when restoring a database.
- Right-click on the TrueNAS Nextcloud database → Delete → confirm
- Right-click on the TrueNAS Nextcloud database server → Create → Database
- Database: nextcloud
- Click ‘Save’
Backup and Restore
Backup TrueCharts Nextcloud Databases
- Right-click on the database itself → Backup…
- Filename: nextcloud.tar
- Format: Tar
- Click ‘Backup’ button
Depending on your setup, this might take seconds or minutes.
You will see a popup message telling you when the process is complete.
To see your backup go to Tools → Storage Manager… (top menu)
Restore Database Backup to TrueNAS NextCloud Database
- Right-click on the TrueNAS Nextcloud database itself → Restore
- Format: Custom or tar
- Filename: click on the folder icon to the right and select the backup just made previously
- Click ‘Restore’ button
Depending on your setup, this might take seconds or minutes.
You will see a popup message telling you when the process is complete.
Update Nextcloud Config
SSH into the TrueNAS server and open the Nextcloud config located in /mnt/truenase-pool/nextcloud/app_data/config/config.php file.
This is what my config looks like – I highlighted (bold) the most important settings to have right:
<?php
$CONFIG = array (
'htaccess.RewriteBase' => '/',
'memcache.local' => '\\OC\\Memcache\\APCu',
'apps_paths' =>
array (
0 =>
array (
'path' => '/var/www/html/apps',
'url' => '/apps',
'writable' => false,
),
1 =>
array (
'path' => '/var/www/html/custom_apps',
'url' => '/custom_apps',
'writable' => true,
),
),
'memcache.distributed' => '\\OC\\Memcache\\Redis',
'memcache.locking' => '\\OC\\Memcache\\Redis',
'redis' =>
array (
'host' => 'ncloud-nextcloud-redis',
'password' => '*****',
'port' => 6379,
),
'upgrade.disable-web' => true,
'passwordsalt' => '*****',
'secret' => '*****',
'trusted_domains' =>
array (
0 => 'localhost',
1 => '192.168.xxx.xxx',
2 => '127.0.0.1',
3 => 'localhost',
4 => 'ncloud-nextcloud-*',
5 => 'ncloud-nextcloud',
6 => 'nextcloud.mydomain.com',
7 => 'collab.mydomain.com',
),
'datadirectory' => '/var/www/html/data',
'dbtype' => 'pgsql',
'version' => '29.0.5.1',
'overwrite.cli.url' => 'https://nextcloud.mydomain.com',
'overwriteprotocol' => 'https',
'dbname' => 'nextcloud',
'dbhost' => 'ncloud-nextcloud-postgres:5432',
'dbport' => '',
'dbtableprefix' => 'oc_',
'dbuser' => 'nextcloud',
'dbpassword' => '*****',
'installed' => true,
'instanceid' => 'ocecp9b4uphu',
'overwritehost' => 'nextcloud.mydomain.com',
'loglevel' => 2,
'maintenance' => false,
'enabledPreviewProviders' =>
array (
1 => 'OC\\Preview\\BMP',
2 => 'OC\\Preview\\GIF',
3 => 'OC\\Preview\\JPEG',
4 => 'OC\\Preview\\Krita',
5 => 'OC\\Preview\\MarkDown',
6 => 'OC\\Preview\\MP3',
7 => 'OC\\Preview\\OpenDocument',
8 => 'OC\\Preview\\PNG',
9 => 'OC\\Preview\\TXT',
10 => 'OC\\Preview\\XBitmap',
11 => 'OC\\Preview\\Movie',
),
'mail_smtpmode' => 'smtp',
'mail_sendmailmode' => 'smtp',
'mail_from_address' => 'mydomain.com',
'mail_domain' => 'protonmail.ch',
'mail_smtpport' => '25',
'mail_smtpauth' => 1,
'mail_smtpname' => '*****@protonmail.ch',
'mail_smtppassword' => '*****',
'mail_smtphost' => 'protonmail-bridge.ix-protonmail-bridge.svc.cluster.local',
'mail_smtpstreamoptions' =>
array (
'ssl' =>
array (
'allow_self_signed' => true,
'verify_peer' => false,
'verify_peer_name' => false,
),
),
'default_phone_region' => 'CH',
'maintenance_window_start' => 1,
);
You can safely ignore all the mail settings as I use the proton-bridge TrueChart app for that – for now.
The following two settings are not critical, but without them set I get warnings in Nextcloud:
- ‘default_phone_region’ => ‘CH’,
- ‘maintenance_window_start’ => 1,
Finishing
I then stopped the TrueNAS Nextcloud instance, started it up again, and took it back out of maintenance mode.
I could immediately login with my credentials from the TrueCharts Nextcloud instance.
I ran some occ integrity checks and scanned all the user data.
Basically that was that.
On my phone I had to login again, and auto upload took a while to kick in again, but it eventually did. I think it helped that I edited the auto-upload configurations on the phone, browsed to the destination paths, and saved the configurations again, but not 100% sure.