Accidentally deleted partially the nextcloud folder at /var/www/nextcloud

hi there

i made a terrible mistake in deleting partially the nextcloud folder at /var/www/nextcloud. it took me maybe a second or two until i recognized the fatal error… what seems to be restored are the following files:

3rdparty AUTHORS config core data ocm-provider public.php version.php

the rest is gone. since i only installed nextcloud today there are not so many files that got deleted. does it make sense to reinstall nextcloud completely? could i possibly resore the data folder? in either case, what has to be done?

thanks for your help!


Nextcloud good practice number 1 :

Do not put DATA folder inside the nextcloud folder.

It’s a real security risk for your files !

You have to create a data folder somewhere else :
Like /data
Or /home/data
Then appli chown -R www-data:www-data on this folder
When installing nextcloud you have to give the good path of data folder.

Good practice 2 :
Always have a backup of :
Your data folder
Your nextcloud folder (containing config folder)
Your database

So you if your data folder has gone… you better start from scratch.

After your installation will be up again -> go and try to make backups of your installation.
And make some tests
Delete the data folder then restore your backup etc…

Then you will be ready to use your nextcloud

1 Like

thanks! but the data folder hasn’t gone!

for the matter of backuping: where’s the mariadb database located?

So you are good to :
Re-download nextcloud and put the missing files/folder …

THEN MOVE THE DATA FOLDER SOMEWHERE ELSE ! And apply the good owner on the folder.

Then modify the config/config.php file, inside there is the path of the data folder, write the new location.

Then enjoy

1 Like

You have to make a DUMP of the database using a mysqldump command. It will output a .sql file, this will be your database backup.

Google it. (Or duckduckgo it, google is evil)

1 Like

sure thing. thanks! yeah, so i’m familiar with mysqldump. i’ve done this before… no google on my machine!

Before making the dump, it is preferable to put your nextcloud instance into MAINTENANCE MODE
You can enable maintenance mode by enabling it in the config file or by the occ command.

Then make the dump.

Then disable maintenance mode.

You can automate this with a script.

1 Like

i reinstalled nextcloud, ran through the setup wizzard and created a temporary user. i moved the old data folder to another location. moved the existing folders/files to the new nextcloud folder (3rdparty AUTHORS config core data ocm-provider public.php version.php) updated the config file with the new data location, checked the ID in the config file which matches the ID in the datafolder. i tried to access the page in the browser and got this error message:

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.

could not figure out where the server log is.

but maybe it makes more sense to do the installation from scratch. as i already mentioned, it’s not a significant loss of data. however, during the second installation i could not chose the username i used during the first installation. how can i erase the protocol that says this user has already been taken?

By deleting your database.

If your using nginx /var/log/nginx
Id it’s apache 2 /var/log/apache2/

1 Like

i’m using apache. however, i cannot figuere out where the database is. i can only see some log files. that’s the content of my apchache2 folder:

access.log nextcloud_access.log.1 other_vhosts_access.log.1
error.log nextcloud_error.log error.log.1 nextcloud_error.log.1
nextcloud_access.log other_vhosts_access.log

would delete the whole folder really resolve the problem?

Again : your database isn’t a file.

You have to use the program mysql for talking with it.

Make research on internet but a sumery could be :
mysql -u root -p
show databases;
(you see the list of database, you see that your nextcloud database is named for exemple : ncDB)
drop database ncDB;
(Your database is gone)

1 Like