Hi, I searched the Issues before opening a new one, none of the existing ones helped me unfortunately.
I got a Intel NUC to replace my Nextcloudbox, with a 120 SSD and 1 TB SATA (for data), Installed Ubuntu Server 16.04 on the SSD and SATA as a Home directory. Installed nextcloud snap and started reading around how i could change the data directory to the SATA (simply creating a nextcloud-data folder in the SATA and pointing nextcloud snap there).
I went with Bind-mounting the SATA to /media/nextcloud and then added it as a external storage in nextcloud. Which worked until i tried to use nextcloud sync on my desktop. It didn't sync and gave me bunch of errors and when i tried to sync with my Android phone it gave me 'malformed server configuration' error. But i can create and upload files in web interface without problem.
I really appreciate the help. Thanks in advance.
Nice hardware choice, that should perform quite a bit better! I just added a wiki page for this, mind taking it for a spin?
I'm on it mate, backing up my data as you discribed at https://github.com/nextcloud/nextcloud-snap/issues/413 with rsync to a USB stick on the nextcloudbox (97GB should take a few hours). Afterwards I'll attach it to the NUC and try to restore with rsync to the new snap.
Nice. Are you wanting to transfer the database as well, or do you only care about the raw data?
Database as well. Full migration from nextcloudbox to NUC. Do you have any suggestions?
Yeah, make sure you dump the database instead of trying to copy it over, I don't think that will work across architectures. There is a mysqldump command as well as a mysql-client command in the snap which should come in handy.
I have no idea how to do that.. :confused: Should I stop the rsync backup?
@Seferi no, don't stop it, you'll need the stuff in common as well. Don't stress, we'll get you through this! @chrauscher posted a gist on #413 that walks through most of the steps necessary, including dumping the database. Take a look at that.
Have you run snap set at all, perhaps to change the ports, or up the PHP memory limit?
Thanks a bunch mate, you are very helpful and I really appreciate it. No I haven't run snap set yet.. Should I?
Just had a look at @chrauscher s gist. I didn't switch on the maintenance mode before the backup is that ok?
And I see that he uses rsync with -Aax option..
Nope, it just means that gist should cover all the steps you need. I'll summarize here:
So:
Put Nextcloud into maintenance mode so nothing changes out from under you:
$ nextcloud.occ maintenance:mode --on
Create a backup of /var/snap/nextcloud/common/, which you're doing now. This will be all the raw data (files, pictures, etc.)
Create a backup of the database:
$ nextcloud.mysqldump > database.bak
Backup the Nextcloud configuration at /snap/nextcloud/current/htdocs/config/config.php. There are more things in /snap/nextcloud/current/ that might prove useful to backup as well (SSL certs, for example. Did you enable HTTPS?)
I didn't switch on the maintenance mode before the backup is that ok?
That just means more files could be uploaded while you're creating a backup. Ideally you'd put it into maintenance mode, but it's also possible that you know you haven't used it and aren't missing anything. Your call there.
I did enable the https on nextcloudbox but I set up a raspberry pi with a nginx reverse proxy in case I want to serve websites later on, and NUC will be going through nginx reverse proxy which has its on lets encrypt cert. So I wont need the old certs from nextcloudbox and wont need to enable the https on NUC.
I have to change the data directory on /snap/nextcloud/current/htdocs/config/config.php to /media/nextcloud before the restore right?
P.S. Backup is taking its time, at 18GB/94GB at the moment...
Yep, you got it.
Once you're to that point, you should be able to import your database on the new snap with nextcloud.mysql-client < database.bak. That will require mysql to have been setup already, so make sure the new snap is installed and to the point of prompting for an admin account before doing that. That will likely need to be run as root.
Ok mate, thanks alot. I'll follow the steps and report back. By the way some of the files are failing to sync on rsync (invalid argument: 22) because of their names probably. Is there a way to sync them all ?
Not sure on that one, google should know. You can always tar them first if necessary.
Should I backup the folders 4378 4953 5130 in /var/snap/nextcloud as well? You mentioned that in your post in #413
EDIT: I tried backing them up as well just in case but /certs/ didn't sync and gave a permission error.
I'm getting this error -bash: database.bak: Permission denied with nextcloud.mysqldump > database.bak
Lots of permission errors.. The usb drive is formatted to FAT, might that be the reason for the permission errors? I can reformat the drive to Ext4 and repeat the whole backup process...
@kyrofa Hi mate, reformatted the usb drive and got no permission errors on backup this time. But I'm getting this error when trying to restore the database:
sudo nextcloud.mysql-client < database.bak
ERROR 1046 (3D000) at line 22: No database selected
@kyrofa In the end restoring database didn't work. I ended up exporting my calenders, contacts, bookmarks etc.. manually, reinstalling snap on the NUC and restoring the app data manually which worked fine. I moved the Data directory to the /media/ as you discribed in your tutorial and synced my data via desktop client... Thanks for your help mate. it should be ok from now on
Glad to hear it, @Seferi! I'm sorry for the delay in response, you know why now :stuck_out_tongue: . I'll try to work through the restore steps for next time. Really would like that import/export feature.
The restore does not work still, I get the error mysql: Error reading file 'UNOPENED' (Errcode: 13 - Permission denied) . Maybe it's an apparmor stuff.