nextcloudpi icon indicating copy to clipboard operation
nextcloudpi copied to clipboard

Data folder deleted after restoring from data-less backup

Open mad73923 opened this issue 2 years ago • 7 comments

I just had massive problems restoring my ncp docker instance after some files got corrupted (due to worn-out SD-card!?)

I make data-less ncp backups every 2nd day and use my own rsync script to backup the data folder. The corrupted files were not part of the data folder! My expectation was to reinstanciate my docker container, mount the same data volume as before, run the ncp-restore and have a happy day.

BUT: After running the ncp-restore with my data-less archive, I realized all the data was gone. The problem seems to be these 2 lines in the nc-restore script: https://github.com/nextcloud/nextcloudpi/blob/dd8fc3dd7d663faf5d916039ee042ef049aaf728/bin/ncp/BACKUPS/nc-restore.sh#L66-L67 Here, the nextcloud folder gets deleted and replaced by the one from the backup. What seems to be good for a backup WITH data can lead to a nightmare in case of a data-less backup. Luckily, I had my own backup of the data folder!!

To fix this, I ran the script step by step and replaced the lines with an rsync command.

mad73923 avatar Jan 28 '22 10:01 mad73923

That is what I have discovered a month ago. Just wanted to restore the "dataless" Backup and all my Data was gone after that.

But luckily I had an external backup.

rondadon avatar Mar 02 '22 11:03 rondadon

That is to be expected. Bear in mind that the php code for Nextcloud is also in the volume together with the data. In the non-docker case, if we have moved the data, then it will honor that but that is a quirk. If you restore a dataless backup in the general case you end up with a clean instance, with the exception I mentioned before

nachoparker avatar Mar 02 '22 16:03 nachoparker

@nachoparker

Thank you for clarification! Indeed I am using the Docker-Version of Nextcloudpi. Again thank you for clarification and have a nice day! :)

rondadon avatar Mar 02 '22 18:03 rondadon

Now it happened! I lost my data by restoring a data-less backup!! @nachoparker can you please please find a better solution. In case a data-less restore is issued, the data folder should not be touched. Please reopen!!

mad73923 avatar May 02 '22 13:05 mad73923

Reopen please!

mad73923 avatar Jun 07 '22 16:06 mad73923

I'll have another look at this

theCalcaholic avatar Jun 07 '22 17:06 theCalcaholic

Thank you! This severe issue made me switch to nextcloud/docker :cry:

mad73923 avatar Jun 08 '22 09:06 mad73923

+1 Bumping this

  • -[ ] A way to restore a backup recursively, like with rsync or something similar and not just replace the nextcloud directory as is when restoring the backup tar.

ZendaiOwl avatar Sep 28 '22 01:09 ZendaiOwl

+1 Bumping this, a note for when I have the time, or if theCalcaholic looks at it before me

  • A stop from restoring a backup and deleting existing files or perhaps a second temporaary file with the current files as a backup, just in case. Unless of course I'm too tired right now and missed it already being there

ZendaiOwl avatar Sep 28 '22 01:09 ZendaiOwl

I have drafted a fix for this: https://github.com/nextcloud/nextcloudpi/pull/1601

It's still untested and can be improved

theCalcaholic avatar Sep 29 '22 00:09 theCalcaholic

The change is now included in version v1.50.5

theCalcaholic avatar Jan 09 '23 11:01 theCalcaholic