Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data folder deleted after restoring from data-less backup #1417

Closed
mad73923 opened this issue Jan 28, 2022 · 11 comments
Closed

Data folder deleted after restoring from data-less backup #1417

mad73923 opened this issue Jan 28, 2022 · 11 comments
Assignees
Milestone

Comments

@mad73923
Copy link
Contributor

mad73923 commented Jan 28, 2022

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:

rm -rf "$NCDIR"
mv -T "$TMPDIR"/nextcloud "$NCDIR" || { echo "Error restoring base files"; exit 1; }

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.

@rondadon
Copy link

rondadon commented Mar 2, 2022

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.

@nachoparker nachoparker self-assigned this Mar 2, 2022
@nachoparker
Copy link
Member

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

@rondadon
Copy link

rondadon commented Mar 2, 2022

@nachoparker

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

@mad73923
Copy link
Contributor Author

mad73923 commented May 2, 2022

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
Copy link
Contributor Author

mad73923 commented Jun 7, 2022

Reopen please!

@theCalcaholic theCalcaholic reopened this Jun 7, 2022
@theCalcaholic
Copy link
Collaborator

I'll have another look at this

@mad73923
Copy link
Contributor Author

mad73923 commented Jun 8, 2022

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

@theCalcaholic theCalcaholic self-assigned this Aug 17, 2022
@victor-rays
Copy link
Collaborator

+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.

@victor-rays
Copy link
Collaborator

victor-rays commented Sep 28, 2022

+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

@theCalcaholic
Copy link
Collaborator

I have drafted a fix for this: #1601

It's still untested and can be improved

@theCalcaholic theCalcaholic added this to the v1.50.3 milestone Sep 29, 2022
theCalcaholic added a commit that referenced this issue Jan 5, 2023
- nc-restore: Keep old data directory if present
- nc-restore: Temporarily move and restore user files during nc-restore

Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com>
theCalcaholic added a commit that referenced this issue Jan 5, 2023
- nc-restore: Keep old data directory if present
- nc-restore: Temporarily move and restore user files during nc-restore

Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com>
theCalcaholic added a commit that referenced this issue Jan 8, 2023
- nc-restore: Keep old data directory if present
- nc-restore: Temporarily move and restore user files during nc-restore

Signed-off-by: Tobias K <6317548+theCalcaholic@users.noreply.github.com>
Signed-off-by: Tobias Knöppler <6317548+theCalcaholic@users.noreply.github.com>
@theCalcaholic
Copy link
Collaborator

The change is now included in version v1.50.5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

No branches or pull requests

5 participants