{"id":15406373,"url":"https://github.com/otherguy/nextcloud-cleanup","last_synced_at":"2025-10-27T13:47:27.737Z","repository":{"id":64267128,"uuid":"454408969","full_name":"otherguy/nextcloud-cleanup","owner":"otherguy","description":"Cleans up files on Nextcloud S3 storage that are left over from canceled uploads","archived":false,"fork":false,"pushed_at":"2022-02-06T13:30:40.000Z","size":33,"stargazers_count":12,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-18T14:07:37.705Z","etag":null,"topics":["kubernetes","nextcloud","s3","scaleway"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/otherguy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-02-01T13:59:40.000Z","updated_at":"2024-09-04T14:07:27.000Z","dependencies_parsed_at":"2023-01-15T07:30:27.212Z","dependency_job_id":null,"html_url":"https://github.com/otherguy/nextcloud-cleanup","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/otherguy/nextcloud-cleanup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otherguy%2Fnextcloud-cleanup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otherguy%2Fnextcloud-cleanup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otherguy%2Fnextcloud-cleanup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otherguy%2Fnextcloud-cleanup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/otherguy","download_url":"https://codeload.github.com/otherguy/nextcloud-cleanup/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/otherguy%2Fnextcloud-cleanup/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262699044,"owners_count":23350232,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kubernetes","nextcloud","s3","scaleway"],"created_at":"2024-10-01T16:21:38.787Z","updated_at":"2025-10-27T13:47:27.642Z","avatar_url":"https://github.com/otherguy.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nextcloud S3 Storage Cleanup\n\nNextcloud has several open issues ([#30762](https://github.com/nextcloud/server/issues/30762),\n[#29841](https://github.com/nextcloud/server/issues/29841)) regarding its inability to clean up\nleft over chunks from bad or canceled uploads, when using S3 object storage as the primary\nbackend.\n\nThe [script itself](clean.php) is extremely simple and will clean up all chunks that are older\nthan a certain time limit.\n\nAs I'm running Nextcloud on [Scaleway Kubernetes](https://www.scaleway.com/en/kubernetes-kapsule/)\nwith Scaleway's S3 compatible [Object Storage](https://www.scaleway.com/en/object-storage/), this\nscript is optimized for my usecase but I will happily accept pull requests to make it more versatile\nand work with other S3 compatible object storage providers.\n\n## Prerequisites\n\nThe script was written for my own usecase and therefore currently only works with the following:\n\n* MySQL database (or MariaDB)\n* Nextcloud version 15 or higher\n* Docker, Kubernetes or local PHP 8+\n\n## Usage\n\nTo make the script as simple as possible, it's bundled in a [Docker image](Dockerfile) that can\nbe run either standalone or in Kubernetes.\n\nThis is designed to be run as a cronjob, e.g. every 60 minutes.\n\nSimply copy the [`.env.example`](.env.example) file to a new `.env` file and adjust the values\nto your setup. Make sure the location that you are running the script from can access both the\nS3 bucket and the Nextcloud database (Firewall rules, IP blocking, etc.).\n\nThen run:\n\n```bash\n$ docker run --rm --env-file=.env otherguy/nextcloud-cleanup:latest\nFound 0 left over files.\nRecovered 0 B from S3 storage.\n```\n\n## Kubernetes CronJob\n\nEdit the [`kubernetes-secret.yml`](kubernetes-secret.yml) file and add the correct environment\nvariables for your database credentials and your S3 bucket details.\n\nThen, apply the secret and [the CronJob](kubernetes-cronjob.yml) to the cluster:\n\n```bash\n$ kubectl apply --validate -f kubernetes-secret.yml -f kubernetes-cronjob.yml\nsecret/nextcloud-cleanup-config configured\ncronjob.batch/nextcloud-cleanup configured\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fotherguy%2Fnextcloud-cleanup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fotherguy%2Fnextcloud-cleanup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fotherguy%2Fnextcloud-cleanup/lists"}