NextcloudPi Error on Restore - Please help

I’m having some issues with NextcloudPI running on an Odroid HC-2. There was a powerfailure a couple of days ago and my NextcloudPI instance crashed.

I’m trying to restore from a backup I have (no data).

Step 1 - Flash latest NextcloudPI img using Etcher
Step 2 - Run through initial NextcloudPi wizard
- Enable USB
- Move Data folder
- Enable Fail2Ban
- Forward Ports
Step 3 - Select NC-Restore from the web menu, copy the path to the backup (/media/myCloudDrive/Backups/nextcloud-bkp_20211115_1636945202.tar.gz) and run through the process.

At this point it starts to run through but I constantly get the following error:

[ nc-restore ] (Thu Nov 25 14:39:59 AST 2021)
check free space…
extracting backup file /media/myCloudDrive/Backups/nextcloud-bkp_20211115_1636945202.tar.gz…
restore files…
restore database…
No datadir found in backup
{“reqId”:“CoqB9E8MfNDifTwM94NJ”,“level”:2,“time”:“2021-11-25T18:48:42+00:00”,“remoteAddr”:"",“user”:"–",“app”:“no app in context”,“method”:"",“url”:"–",“message”:“Temporary directory /media/USBdrive/ncdata/tmp is not present or writable”,“userAgent”:"–",“version”:“”}
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
{“reqId”:“CoqB9E8MfNDifTwM94NJ”,“level”:3,“time”:“2021-11-25T18:48:43+00:00”,“remoteAddr”:"",“user”:"–",“app”:“PHP”,“method”:"",“url”:"–",“message”:{“Exception”:“Error”,“Message”:“fopen(/media/USBdrive/ncdata/data_dir_writability_test_619fda8ba91f9.tmp): failed to open stream: Permission denied at /var/www/nextcloud/lib/private/legacy/OC_Util.php#809”,“Code”:0,“Trace”:[{“function”:“onError”,“class”:“OC\Log\ErrorHandler”,“type”:"::",“args”:[2,“fopen(/media/USBdrive/ncdata/data_dir_writability_test_619fda8ba91f9.tmp): failed to open stream: Permission denied”,"/var/www/nextcloud/lib/private/legacy/OC_Util.php",809,{“config”:{“class”:“OC\SystemConfig”},“l”:{“class”:“OC\L10N\LazyL10N”},“errors”:[],“CONFIG_DATADIRECTORY”:"/media/USBdrive/ncdata",“webServerRestart”:false,“0”:“And 4 more entries, set log level to debug to see all entries”}]},{“file”:"/var/www/nextcloud/lib/private/legacy/OC_Util.php",“line”:809,“function”:“fopen”,“args”:["/media/USBdrive/ncdata/data_dir_writability_test_619fda8ba91f9.tmp",“w”]},{“file”:"/var/www/nextcloud/lib/private/Console/Application.php",“line”:161,“function”:“checkServer”,“class”:“OC_Util”,“type”:"::",“args”:[{“class”:“OC\SystemConfig”}]},{“file”:"/var/www/nextcloud/console.php",“line”:99,“function”:“loadCommands”,“class”:“OC\Console\Application”,“type”:"->",“args”:[{“class”:“Symfony\Component\Console\Input\ArgvInput”},{“class”:“Symfony\Component\Console\Output\ConsoleOutput”}]},{“file”:"/var/www/nextcloud/occ",“line”:11,“args”:["/var/www/nextcloud/console.php"],“function”:“require_once”}],“File”:"/var/www/nextcloud/lib/private/Log/ErrorHandler.php",“Line”:92,“CustomMessage”:"–"},“userAgent”:"–",“version”:“”}
Your data directory is not writable
Permissions can usually be fixed by giving the webserver write access to the root directory. See

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:168
Stack trace:
#0 /var/www/nextcloud/console.php(99): 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}{“reqId”:“CoqB9E8MfNDifTwM94NJ”,“level”:3,“time”:“2021-11-25T18:48:43+00:00”,“remoteAddr”:"",“user”:"–",“app”:“PHP”,“method”:"",“url”:"–",“message”:“fopen(/media/USBdrive/ncdata/nextcloud.log): failed to open stream: Permission denied at /var/www/nextcloud/lib/private/Log/File.php#85”,“userAgent”:"–",“version”:“”}

I have a hard time understanding the output, so I’m hoping some here can help me out.


It says:

Your data directory is not writable
Permissions can usually be fixed by giving the webserver write access to the root directory. See

Thanks for the info, I did see that but the link only brings me to the Nextcloud Docs. I couldn’t find anything regarding admin dir permissions.

The part that mentions permissions in the docs is this section

It is best to configure your data directory location at installation, as it is difficult to move after installation. You may put it anywhere; in this example is it located in /opt/nextcloud/ . This directory must already exist, and must be owned by your HTTP user.

Specifically, this part

This directory must already exist, and must be owned by your HTTP user

The HTTP user with ncp on a debian base with apache2 is www-data

So what needs to be done is to create the folders on the drive (if they don’t already exist), and set the permissions so they are owned or read/write-able by www-data.

Set the permissions for a directory like so

sudo chown -R www-data:www-data /media/USBdrive/ncdata

It can be seen in the error message what folder is missing the correct permissions


fopen(/media/USBdrive/ncdata/data_dir_writability_test_619fda8ba91f9.tmp): failed to open stream: Permission denied

Did you try nc-app-fix-permissions from ncp pannel?