A short back story why I am posting this. I switched my Nextcloud instance from a Docker container to TKL Nextcloud LXC on Proxmox. The reason behind this switch was, I could not get the Linuxserver Nextcloud upgraded and if I spin up a new Docker container, I might encounter the same problem. The TKL Nextcloud LXC is very easy to upgrade.
I have my files and my folks files sitting in the
/data of my Nextcloud Docker container and need to move these files to the new TKL Nextcloud. This is the goal of this post. Unfortunately, it is not as easy as copying the files from point A to point B because of the mariaDB information also need to be moved or register the new files to the new mariaDB. I do not know much about databases, but it is easier for me to just register (as I call it) the new files to the TKL Nextcloud DB.
Fortunately, both my Docker Nextcloud and TKL Nextcloud
/data resides on my NAS. This makes the copying the files a bit easier since I don’t have to send it over the network. Also, I keep saying copy because that is what I am about to do. I am not moving the files unless I am 100% the files are showing up on the new Nextcloud web UI.
/data resides on the same NAS, I would use the command cp. If it is over the network, I might use either rsync or scp. I have to SSH-in to my NAS and copy the files from directory A to directory B. In this example, I would just copy a single file to make a point. That this method works.
Nextcloud saves the users data files in the
/data/<username>/files/ directory. If you do not remember where you
/data is, you can execute this command
grep -r '/var/www/' -e "^…datadirectory' => '/". Below I will be copying a file named text.txt from old Nextcloud instance to the new instance.
# To copy the files from source to the target directory cp /mnt/user/Cloud/nextcloud/networkshinobi/files/test.txt /mnt/user/Cloud/nextcloud_lxc/networkshinobi/files/test.txt
Once the test.txt has been copied, when you login to your new Nextcloud instance (in my case TKL Nextcloud), the test.txt file is nowhere to be found. The reason is why the file is not showing up in the web UI the database does not know the file exist. To get this file registered to the database we need to SSH-in to the TKL Nextcloud and execute the
# By default the occ file is not executable, so make sure occ is executable cd /var/www/nextcloud chmod 744 occ # Execute the files scan via the www-data user # This may take awhile depending on the amount of data sudo -u www-data php occ files:scan --all
If you are login as the root user, you may have to use the command
su www-data -s /bin/sh and use the command
php occ files:scan --all.
Then the output should be something similar to this
... Omitted for brevity .... Make sure you're running the scan command only as the user the web server runs as Starting scan for user 6 out of 6 (networkshinobi) +---------+-------+--------------+ | Folders | Files | Elapsed time | +---------+-------+--------------+ | 22 | 41 | 00:00:00 | +---------+-------+--------------+
Now, if you are already logged in to the web UI, just refresh the Nextcloud page and the copied file should show up.
Thanks for viewing this post. Cheers!