Cannot restore nextcloudpi backups

I’ve been trying to get an instance of nextcloudpi working after it having died a long while back. There was an issue with the lets-encrypt script, but after that was fixed I tried upgrading. Unfortunately that didn’t work so I tried making a backup of my nextcloudpi using nc-backup.

Short story: I’ve tried two different backups of the same machine to two fresh nextcloudpi docker instances and also to a nextcloudpi native install on debian (using the script from own-your-bits). I’ve also tried restoring a much older backup that I’ve used previously and is known to work to the debian install - all of them have given the message “invalid backup file”.

All of these backups are from nextcloudpi instances using nextcloud13, while I believe everything I’ve tried restoring on is nextcloud 14, so that might be the issue. If not I have no idea. Any chance anyone knows of a way to make these compatible for restoration so that I can get a current up-to-date instance with my old database (i can pull the data in manually if necessary)?

As a side note, I’m really loving the nextcloudpi package - assuming I can get it to work. Nacho seems to have done a great job at taking a lot of the work out of setup for home users for me, and backups, restores, and lets encrypt are all there out of the box. Unfortunately I just can’t get it to work right :(. It seems that it doesn’t have as large of a support base as nextcloud as a whole and I worry that my problems just won’t be addressed because nobody uses it. For example - are nc-backup and nc-restore baked into nextcloud, or is that something he baked into nextcloudpi? I’m wondering if it’s time to go for a more supported version of NC? Regardless, I super appreciate all of Nacho’s work.

That means your backup file doesn’t have the backup files in it. What is the content of the tar file?

I would say that NCP has a pretty big userbase. nc-backup and company are NCP addition, they are not part of Nextcloud

So I’ve got 4 unique backup files that I can see. Oddly enough they don’t all appear to be the same.

One doesn’t include data - it only has a file called nextcloud-sqlbkp_[DATE].bak and another file that I think is a symlink and points to /data/app named “nextcloud”. I say i think it’s a symlink because when I view the tar without extracting it there is a field in Xarchiver that says “points to” and it has a value there. But I’m not really a linux guy so that could be a poor assumption on my part.

I believe this was the first backup I did and I didn’t select “include data”.

I have two additional backups that are similar - they contain a similarly named sqlbkp file with their own date stamps and the file named “nextcloud” that I believe is a symlink. These also contain a directory named “data”. I was thinking perhaps the symlink was supposed to link to a directory in here, but there are none that are named “app”. There are two that start with “appdata”.

My fourth file is a little pecuiliar. It was a copy of another file that I made simply to shorten the name and file path to make it easier to type into the nc-restore field. Oddly enough I cannot find it’s original copy. Like the others it contains the sqlbkp file, but unlike the others instead of having a data directory and a symlink named “nextcloud” it just has a directory named nextcloud. It contains everything I would have expected to see in the other “data” directories.

Did all of that make sense?

I guess at this point I’m find with just recovering from a database only and pulling the data in manually then running the tool to detect the new data and correct permissions. But I haven’t been able to get the restores to work. Of note - I’m not sure I ever tried the backup that contained just the database and not the data. I can try that if you think it would make a difference.

Yes, it makes sense. Unfortunately, your three first backups are bad, because of some bug in docker backups that was corrected some time ago. Your last backup is fine: database backup + nextcloud files + data.

You should be able to restore that one, and if your container is up to date (through ncp-update) your future backups will be fine as well.

Thanks for your feedback, it is very important to notice things and fix them.

Hmmm… I’m pretty sure that was the one I tried first as I was most hoping it would work. I believe it gave me the same “invalid backup file” message. I’ll try it again when I get home to be sure.

It’s worth noting that I believe this tar only had one file and one directory. I think the data was within the nextcloud directory, but it would have been a subdirectory, not a separate directory at the same level as the sql backup and nextcloud directory. Is that normal?

it can be, depending if you selected with or without data, and depending on wether you moved the data with nc-datadir

Alright, I swear I’ve tried that backup with no success, but this time was different. We’re getting somewhere. Unfortunately I still got an error, but this looks fixable.

Launching nc-restore
extracting backup file /media/data3/data/oct-10-bak.tar...
restore files...
restore database...
no datadir found in backup
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Cannot create "data" directory
This can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/13/go.php?to=admin-dir_permissions

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:148
Stack trace:
#0 /var/www/nextcloud/console.php(89): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')
#2 {main}Cleanup...
Done. Press any key...

It’s worth pointing out that A) I’m running on a 64 bit debian system and B) I’ve already run nc-datadir to change the data directory. So I’m guessing something went wrong during that process, not the restore. I tried running nc-datadir again and got this:

Launching nc-datadir
Error reading data directory. Is NextCloud running and configured?
Done. Press any key...

Thoughts?

For good measure I ran nc-update and got the below output, which I think is having the same issue as what the backup was having.

Downloading updates
Performing updates
Installing DDNS_spDYN
Installing nc-backup
Installing nc-restore
Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Cannot create "data" directory
This can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/13/go.php?to=admin-dir_permissions

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:148
Stack trace:
#0 /var/www/nextcloud/console.php(89): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')
#2 {main}Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Cannot create "data" directory
This can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/13/go.php?to=admin-dir_permissions

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:148
Stack trace:
#0 /var/www/nextcloud/console.php(89): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')
#2 {main}Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Cannot create "data" directory
This can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/13/go.php?to=admin-dir_permissions

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:148
Stack trace:
#0 /var/www/nextcloud/console.php(89): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')
#2 {main}Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Cannot create "data" directory
This can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/13/go.php?to=admin-dir_permissions

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:148
Stack trace:
#0 /var/www/nextcloud/console.php(89): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')
#2 {main}Nextcloud or one of the apps require upgrade - only a limited number of commands are available
You may use your browser or the occ upgrade command to do the upgrade
Cannot create "data" directory
This can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/13/go.php?to=admin-dir_permissions

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:148
Stack trace:
#0 /var/www/nextcloud/console.php(89): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')
#2 {main}NextCloudPi updated to version v0.64.7
Done. Press any key...

P.S. I can confirm that what I had tried to configure as the data directory is mounted and there, in case you were wondering. Doesn’t mean it’s not broke as hell, but it’s external and exists (I have a habit of manually adding that to my fstab instead of using the nc-automount).

try pointing datadir in /var/www/nextcloud/config/config.php to the real path /media/xxx

quick note, I named the mount point for my data dir “ncdata” when I tried to move data there the first time it created a subdirectory named “ncdata” so I believe my data folder is actually /media/USB/ncdata/ncdata for purposes of the config.php file. Though perhaps I’m wrong and it should be up a level. Either way I made this change as you said and tried nc-update. It worked good. Horray!

Then I tried to do a restore of the working backup file. It completely overwrote my config.php file (returning it to the state of what it was before I edited it) and gave me the same original error. I suppose this is to be expected that the restore would overwrite my config file, but… I feel like at the same time this breaks the restore process. Possibly because this came from a docker instance originally? Still the data dir is one thing I can think of that shouldn’t be overwritten when restoring a backup.

Thoughts?

maybe you did the backup during an upgrade and that messed things up??

I don’t know. There was nothing to indicate a problem when I created the backup. I was hoping to find a bootable version of my NCP in a working state (I had one when we had the lets encrypt issue), but I haven’t been able to find that. I did find another backup file I haven’t tried, but I’m running low on time right now. If that doesn’t work is there a way to just copy the database over from either one of my backups or a semi-broken docker instance?

update: that backup didn’t work. I’m rather confused, I swear one of my old backups that had the 3 files (one data directory named “Data”, one symlink named “nextcloud”, and one nextcloud-sqlbkp_######.bak) worked once. I’ve had a previous failure that required a restore, and that’s where I thought it was, and the time/date seems correct. Is it possible this would have restored in an older version of NCP?

I don’t want to give up, but I’m out of ideas.

Yes, you can with a command similar to

mysql -u root nextcloud <  nextcloud-sqlbkp_xxxxxx.bak

, then copy your files to the data folder and run nc-scan

Make sure to install the same NC version than the one the database backup was running on

If I need to downgrade is that possible, or would I have to make sure to install a fresh instance at or before the desired version (updating to the desired version if necessary)? Also, just to make sure I understand what it is I’m doing - What is the purpose of the “<” character in that line?

Alright, for kicks while I’ve been waiting I’ve installed a fresh new system. This has been giving me a chance to experiment with XFCE ad little and I’m gonna try LXDE this time. Either way, what can I do to install a specific version of nextcloudpi? I’m using the command on your website: # curl -sSL https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/install.sh | bash and I tried modifying that URL to see if I could browse what’s available there and had no luck. Do I need to download that script and modify it?

what is your hardware again? raspberry pi?

In any case, you can install a new instance, then run nc-nextcloud followed by nc-init in order to install the apropriate Nextcloud version, then restore the database with the above command ( the < nextcloud-sqlbkp_xxxxxx.bak means read backup from xxx.bak file), then copy the files to the right place, then run nc-scan

Used to be a pi, but I’m moving to a debian install on a small PC. Something like this: Amazon link just because I had it lying around. I’ll give it a shot later tonight. Thanks.

Any idea how to find the version of nextcloud from the database file? I opened it in a text editor and the top 3 lines show:

– MySQL dump 10.16 Distrib 10.1.26-MariaDB, for debian-linux-gnueabihf (armv7l)

– Host: localhost Database: nextcloud


– Server version 10.1.26-MariaDB-0+deb9u1

you don’t know if it was NC12, 13…