Troubles after moving the data folder

Hey guys

So, following a fresh installation, I moved the data directory to a new location, as mentioned here.

Afterwards everything worked fine, except that I couldn’t upload files from any extension or any user (returned “The operation is forbidden”).

Trying to solve that out I got things even worst and now I’m getting “The operation is forbidden” for every file action (open, save, edit etc.). So actually the system is corrently unusable.

System details:
Nextcloud V. 12.0.5
Debian Jessie
mysql Ver 15.1 Distrib 10.2.12-MariaDB
intel i3 1.8GHz

config.php shows:

$CONFIG = array (                                                                                                                                                                                                  
  'instanceid' => 'xxxxxxxxxxx',                                                                                                                                                                                  
  'passwordsalt' => 'xxxxxxxxxxx',                                                                                                                                                              
  'secret' => 'xxxxxxxxxxxxx',                                                                                                                                                  
  'trusted_domains' => 
  array (                                                                                                                                                                                                          
0 => '',                                                                                                                                                                                      
1 => '',                                                                                                                                                                          
  'datadirectory' => '/srv/dev-disk-by-label-HDD/nextcloud/data/',         //this is the new data location                                                      
  'overwrite.cli.url' => '',
  'dbtype' => 'mysql',                                                                                                                                                                                             
  'version' => '',                                                                                                                                                                                         
  'dbname' => 'nextcloud',                                                                                                                                                                                         
  'dbhost' => '',                                                                                                                                                                                         
  'dbport' => '',                                                                                                                                                                                                  
  'dbtableprefix' => 'oc_',                                                                                                                                                                                        
  'mysql.utf8mb4' => true,                                                                                                                                                                                         
  'dbuser' => 'Shakarum',                                                                                                                                                                                          
  'dbpassword' => '*********',                                                                                                                                                                                     
  'installed' => true,                                                                                                                                                                                             
  'mail_smtpmode' => 'smtp',                                                                                                                                                                                       
  'mail_smtpauthtype' => 'LOGIN',                                                                                                                                                                                  
  'maintenance' => false,                                                                                                                                                                                          

nextcloud.conf shows:

Alias /nextcloud "/var/www/html/nextcloud/"                                                                                                                                                                        
<Directory /var/www/html/nextcloud/>                                                                                                                                                                               
 Options +FollowSymlinks                                                                                                                                                                                           
 AllowOverride All                                                                                                                                                                                                 
 <IfModule mod_dav.c>                                                                                                                                                                                              
  Dav off                                                                                                                                                                                                          
 SetEnv HOME /var/www/html/nextcloud                                                                                                                                                                               
 SetEnv HTTP_HOME /var/www/html/nextcloud                                                                                                                                                                          

Any help is possible?


Did you make sure that the webserver user owns that directory?

How do I check that? Sorry, I’m kinda new in this.

Execute command:
ls -ld /srv/dev-disk-by-label-HDD/nextcloud/data/
and post the output here.

root@OpenMediaVault:/var/www# ls -ld /srv/dev-disk-by-label-HDD/nextcloud/data/
drwxrws--- 8 www-data users 4096 Jan 27 13:14 /srv/dev-disk-by-label-HDD/nextcloud/data/ 


what is the output of
ls -ld /var/www/html/nextcloud/

root@OpenMediaVault:/srv/dev-disk-by-label-HDD/nextcloud/data#  -ld /var/www/html/nextcloud/                                                                                                                       
drwxr-xr-x 15 www-data www-data 4096 Jan 24 21:17 /var/www/html/nextcloud/

I think maybe you forgot to the “/data” folder. So here it is -

root@OpenMediaVault:/srv/dev-disk-by-label-HDD/nextcloud/data# ls -ld /var/www/html/nextcloud/data                                                                                                                 
drwxrwx--- 5 www-data www-data 4096 Jan 26 11:26 /var/www/html/nextcloud/data

can you execute the following command and check whether that solved the problem:
chown -R www-data:www-data /srv/dev-disk-by-label-HDD/nextcloud/data/

Unfortunately it didn’t (I also restarted mariadb and apache2).

So. Is everything working when you move it back? If yes, it should definetly be a permissions problem.
Keep in mind that you should stop apache2 before moving the data.

I tried to change it back but it is still not working. But I don’t know if after I returned it back the filesystems are synced, as I made some changes to the files inbetween. I’m afraid I messed it up with those attempts…

Maybe it has something to do with the NAS service that I’m running on the same machine (OpenMediaVault)?


Might be possible, but only if you OpenMediaVault directly accesses the nc-data folder. Which would be a bad idea anyway since your database won’t be able to track changes and your sync-clients wouldn’t sync properly.

I assume you made a fresh backup before changing the directory in the first place?
You might have to revert back to that backup. It’ll be faster than figuring out what the problem is right now.

Once you restored from backup, start nc maintenance mode, stop sql service and stop apache.
Change the data directory to your liking and chown -r www-data:www-data it.
Put the new path into your config.php and start your services. After that, disable mainenance mode.

At least that’s how I did move my data folder.

I copied the old data and now after the log in I’m getting (in the web UI) -

Internal Server Error

The server encountered an internal error and was unable to complete your request.
Please contact the server administrator if this error reappears multiple times, please include the technical details below in your report.
More details can be found in the server log.

Which is quite unfortunate… It seems that every step I do just make things worst :frowning:

Is there a way to reset everything? I don’t care about the data, there was nothing important there.

Ok, I removed Nextcloud and reinstalled the whole thing and all problems were solved…

1 Like