Migration Nextcloud

penflame

Cadet
Joined
Aug 6, 2020
Messages
9
Hi,
I'm French user to Truenas since many years.
I was using Truenas CORE but while waiting for the development of SCALE, I migrated to Proxmox.
But SCALE is now in RC ^^
I trie to migrate my Nextcloud LXC to Nextcloud Apps in SCALE.
This is my experience return:
- Step 1 - Install Nextcloud App on Truenas SCALE and enter in maintenance mode on Old Nextcloud
- Step 2 - Get admin acces to database create:
Code:
nano /mnt/STORAGE_Path/UserDATA/config/config.php in shell, get 'dbuser' => 'oc_admin' and 'dbpassword' variable
in shell, get 'dbuser' => 'oc_admin' and 'dbpassword' variable
- Step 3 - On Old Nextcloud instance, create seem user and password for export (my database is migrate to PostgreSQL )
Code:
CREATE USER oc_admin WITH PASSWORD 'xxxxxxxx';

Code:
CREATE DATABASE nextcloud TEMPLATE template0 ENCODING 'UNICODE';

Code:
ALTER DATABASE nextclouddb OWNER TO oc_admin;

Code:
GRANT ALL PRIVILEGES ON DATABASE nextclouddb TO oc_admin;

Code:
ALTER ROLE oc_admin superuser;

Code:
\q

And export your databe
Code:
PGPASSWORD="xxxxxxxx" pg_dump nextclouddb -h localhost -U oc_admin  -f nextcloud-sqlbkp_`date +"%Y%m%d"`.bak

- Step 4 - Import your data
Code:
scp -r root@IP_OLD_Nextcloud:/root/nextcloud-sqlbkp_`date +"%Y%m%d"`.bak /mnt/STORAGE_Path/UserDATA

Code:
scp -r root@IP_OLD_Nextcloud:/media/UserDATA/data/ /mnt/STORAGE_Path/UserDATA

- Step 5 - Enter in maintenance mode
Code:
nano /mnt/STORAGE_Path/UserDATA/config/config.php
add 'maintenance' => true, after <?php
- Step 6 - Get name Pods:
Code:
k3s kubectl get -n ix-nextcloud pods

- Step 7 - Inject data and import database:
Code:
k3s kubectl exec -n ix-nextcloud --stdin --tty nextcloud-postgres-59fdc6fc6-9tkxb -- sh -c 'PGPASSWORD="xxxxxxxx" psql -h localhost -U oc_admin -d template1 -c "DROP DATABASE \"nextcloud\";"'

Code:
k3s kubectl exec -n ix-nextcloud --stdin --tty nextcloud-postgres-59fdc6fc6-9tkxb -- sh -c 'PGPASSWORD="xxxxxxxx" psql -h localhost -U oc_admin -d template1 -c "CREATE DATABASE \"nextcloud\";"'

Code:
k3s kubectl cp /mnt/STORAGE_Path/UserDATA/nextcloud-sqlbkp_20211103.bak ix-nextcloud/nextcloud-postgres-59fdc6fc6-9tkxb:/tmp

Code:
k3s kubectl exec -n ix-nextcloud --stdin --tty nextcloud-postgres-59fdc6fc6-9tkxb -- sh -c 'PGPASSWORD="xxxxxxxx" psql -h localhost -U oc_admin -d nextcloud -f /tmp/nextcloud-sqlbkp_20211103.bak'

- Step 8 - Restart and exit maintenance mode

Bug:
- SCP does'nt copy ACL right
- Change ACL for data " chown -R www-data:www-data /var/www/html/ "
 

penflame

Cadet
Joined
Aug 6, 2020
Messages
9
If any one has better idea, i'm interested. It's just my methode.

I have an error with network.

My old Nextcloud has https redirection and with K3S it's node port 9001.

I doesnt succeeds to map easely port 443 to 9001 with my box.
Can we creat another ip specific for Nextcloud?
 

Heracles

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

Here, I do differently. I run Nextcloud from the official Docker image. That container is using Docker volumes to preserve the files that must survive during upgrades (like config). I also run a MariaDB in a second container.

To do backups, I just do a tarball of each volumes and an SQLDump from the database. To restore, I restore the SQLDump, restore the Docker volumes and re-create the container using these volumes. That is good either to restore in the same servers or in completely new servers should I need (serve as DR and maintenance backups).
 
Top