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

[Bug]: Existing directories deleted from /var/www/html PV when deploying docker image on kubernetes #1925

Open
6 of 9 tasks
anomaly256 opened this issue Feb 24, 2023 · 8 comments
Labels
bug data persistence Volumes, bind mounts, etc.

Comments

@anomaly256
Copy link

⚠️ This issue respects the following points: ⚠️

  • This is a bug, not a question or a configuration/webserver/proxy issue.
  • This issue is not already reported on Github (I've searched it).
  • Nextcloud Server is up to date. See Maintenance and Release Schedule for supported versions.
  • Nextcloud Server is running on 64bit capable CPU, PHP and OS.
  • I agree to follow Nextcloud's Code of Conduct.

Bug description

I just moved my existing data directory to data-backup and rm'd the other files from the pv in order to start fresh as I was having issues with the original install that had been upgraded and moved many times since Nextcloud forked from Owncloud.

I was expecting to be able to move my files back into the new data dir once provisioned and issue a files:scan to reimport them.

Yet for some reason, the Nextcloud docker image's provisioning scripts just arbitrarily deletes the existing content of the PV? Including directories it doesn't even handle itself?

Why?

Luckily I have most of my family photos backed up etc. But why? Why do this? Fail with an error message if you want to prevent existing directories getting in the way of anything but don't just delete them without warning. This is just.... why??

Steps to reproduce

  1. Rename existing data dir
  2. Remove nextcloud base files and DB to start a fresh install
  3. Panic as your renamed data-dir is deleted when it need not be

Expected behavior

Don't delete directories you don't typically manage. OR fail with a warning if you must and force the operator to take an action instead of dropping their files without any kind of prompting - not in the cli nor in the provisioning UI. Just .. why???

Installation method

Official All-in-One appliance

Operating system

Debian/Ubuntu

PHP engine version

PHP 8.1

Web server

Apache (supported)

Database engine version

PostgreSQL

Is this bug present after an update or on a fresh install?

Fresh Nextcloud Server install

Are you using the Nextcloud Server Encryption module?

None

What user-backends are you using?

  • Default user-backend (database)
  • LDAP/ Active Directory
  • SSO - SAML
  • Other

Configuration report

No response

List of activated Apps

Just the base apps

Nextcloud Signing status

No response

Nextcloud Logs

No response

Additional info

Your options for source only list community docker images but the docker hub repo says "official"

@anomaly256
Copy link
Author

anomaly256 commented Feb 24, 2023

Should also note that this pv+pvc were pre-existing and not defined by the k8s deployment, the old contents were present initially until the nextcloud:production docker image's provisioning scripts ran.

@szaimen szaimen transferred this issue from nextcloud/server Feb 24, 2023
@anomaly256
Copy link
Author

anomaly256 commented Feb 24, 2023

I'm guessing this from https://github.com/nextcloud/docker/blob/master/25/apache/entrypoint.sh#L150

rsync $rsync_options --delete --exclude-from=/upgrade.exclude /usr/src/nextcloud/ /var/www/html/

is to blame. --delete passed to rsync before checking any other dirs exist apart from those in /usr/src/nextcloud

edit: Thanks for moving this to the right place @szaimen

@patman-cp
Copy link

I hit this when trying to get a corrupted and failed nextcloud setup working again - I wanted to leave existing files as-is so pointed the nextcloud volume at my existing directory and was surprised when all existing files were wiped.

Luckily I backed up the every thing first - I was about to backup only the app store files, but decided backing up everything was a better idea. These files aren't critical to me, so I didn't have an existing backup (these are mainly images and videos I don't have space for on my phone but I want to keep them).

Not sure how I'll get the previous files into this new instance.

@patman-cp
Copy link

Opened a PR here:

#2063

@PatrickHuetter
Copy link

This issue is huge. Had a running nextcloud instance and today it deleted the whole data directory after a docker container restart within kubernetes! Luckily i have some backup but this is really critical for a cloud software!

@joshtrichards
Copy link
Member

Docs note this today and describe how to add additional custom folders if necessary (though it's probably best to place them outside of Nextcloud's installation folder entirely as noted too): https://github.com/nextcloud/docker?tab=readme-ov-file#custom-volumes

@patman-cp
Copy link

Docs note this today

That's not a justification for leaving this as-is. Plus the documentation doesn't anything about using a named volume, it's placement at the end of the documentation makes it seem like a minor warning, and it's in the "Custom volumes" section so it looks like it only applies if you are using an additional custom volume.

At a minimum this should fail rather than silently delete existing data - the user can easily delete the data themselves or script this for repeated uses.

@joshtrichards
Copy link
Member

Yes, hence why the issue isn't closed out. My comment was updating on the status of things.

Your associated PR (thank you, btw) has had review comments on it for months. If you want something to change, look there. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug data persistence Volumes, bind mounts, etc.
Projects
None yet
Development

No branches or pull requests

4 participants