{"id":18360159,"url":"https://github.com/wekan/wekan-cleanup","last_synced_at":"2025-06-18T18:08:41.636Z","repository":{"id":48323272,"uuid":"83427771","full_name":"wekan/wekan-cleanup","owner":"wekan","description":"Python wrapper to clean up Wekan database","archived":false,"fork":false,"pushed_at":"2024-02-02T15:18:11.000Z","size":49,"stargazers_count":16,"open_issues_count":1,"forks_count":12,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-04-06T13:37:17.729Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/wekan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-28T12:06:00.000Z","updated_at":"2024-10-03T23:06:21.000Z","dependencies_parsed_at":"2023-12-05T15:53:47.164Z","dependency_job_id":"22ad9795-e61a-4f62-96e6-f677367e508a","html_url":"https://github.com/wekan/wekan-cleanup","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/wekan/wekan-cleanup","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wekan%2Fwekan-cleanup","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wekan%2Fwekan-cleanup/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wekan%2Fwekan-cleanup/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wekan%2Fwekan-cleanup/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/wekan","download_url":"https://codeload.github.com/wekan/wekan-cleanup/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/wekan%2Fwekan-cleanup/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260606522,"owners_count":23035354,"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":[],"created_at":"2024-11-05T22:26:51.629Z","updated_at":"2025-06-18T18:08:36.622Z","avatar_url":"https://github.com/wekan.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# wekan-cleanup\n\nTools to clean up Mongodb database and delete archived cards / list / boards (after few months)\n\nUsing Python3.\n\n## Local Installation\n\nNeed to have below Python module : pymongo\n\n    pip install pymongo\n\nYou need to have authentification setup on Mongo database and port opened (if docker) and create user :\n\n    use admin\n    db.createUser({user: \"admin\",pwd: \"admin123\",roles: [ \"readWrite\"]})\n\nWekanCleanUp will manage below actions :\n\n- Set in lowecase email of users in database (alert if duplicated email)\n- Delete archived boards older that day_to_keep_board_arch\n- Delete live boards (with no cards into) older than day_to_keep_board_nocard\n- Removing from boards deleting users (if user deleted from database...)\n- Delete archived lists older that day_to_keep_list_arch\n- Delete archived cards older that day_to_keep_card_arch\n- Delete all the orphans objects at the end (lists,cards,checklists,cards_comments,attachements,files,chunks,activities)\n\nYou need to update parameters before executing it\n\n    # Parameters\n    day_to_keep_board_arch = 30\n    day_to_keep_list_arch = 30\n    day_to_keep_card_arch = 60\n    day_to_keep_board_nocard = 15\n    mongo_user = 'admin'\n    mongo_password = 'admin123'\n    mongo_server = 'localhost'\n    mongo_port = '27017'\n\n## Docker Installation\n\n\n1. Build Docker Image\n\nRun the following command in the source root directory to build the docker image:\n```\n    docker build -t wekan-cleanup .\n```\n\n### With DB authentication\n\n\n2. Create MongoDB User\n\nYou still need a MongoDB user with access to the wekan database. \nIf MongoDB is running in a docker container you could enter the container via docker (e.g. `docker exec -it wekan-db mongo`) and create the user:\n```\n    use admin\n    db.createUser({user: \"admin\",pwd: \"admin123\",roles: [ \"readWrite\"]})\n```\n\n3. Save the password as a file\n\nSave the password as the content of a file on your computer, for example:\n```\n    echo \"admin123\" \u003e .MONGO_PASSWORD\n```\n\n4. Run the docker container with your custom settings\n\nBefore you execute this command, please make sure that you have a backup of your MongoDB.\n\n```\ndocker run \\\n    --rm \\\n    -v \"$PWD/.MONGO_PASSWORD:/.MONGO_PASSWORD\" \\\n    --env \"MONGO_PASSWORD_PATH=/.MONGO_PASSWORD\" \\\n    --env \"MONGO_USER=admin\" \\\n    --env \"MONGO_SERVER=wekandb\" \\\n    --env \"MONGO_PORT=27017\" \\\n    --env \"MONGO_DATABASE=wekan\" \\\n    --env \"DAYS_TO_KEEP_BOARD_ARCHIVE=30\" \\\n    --env \"DAYS_TO_KEEP_LIST_ARCHIVE=30\" \\\n    --env \"DAYS_TO_KEEP_CARD_ARCHIVE=60\" \\\n    --env \"DAYS_TO_KEEP_CARD_NOCARD=15\" \\\n    --network \"wekan-mongodb_wekan-tier\" \\\n    wekan-cleanup\n```\n\n### Without DB authentication\n**NOT** recommended in production environments\n\n2. Run the docker container with your custom settings\n\nBefore you execute this command, please make sure that you have a backup of your MongoDB.\n\n```\ndocker run \\\n    --rm \\\n    --env \"MONGO_USER_AUTHENTICATION=false\" \\\n    --env \"MONGO_SERVER=wekandb\" \\\n    --env \"MONGO_PORT=27017\" \\\n    --env \"MONGO_DATABASE=wekan\" \\\n    --env \"DAYS_TO_KEEP_BOARD_ARCHIVE=30\" \\\n    --env \"DAYS_TO_KEEP_LIST_ARCHIVE=30\" \\\n    --env \"DAYS_TO_KEEP_CARD_ARCHIVE=60\" \\\n    --env \"DAYS_TO_KEEP_CARD_NOCARD=15\" \\\n    --network \"wekan-mongodb_wekan-tier\" \\\n    wekan-cleanup\n```\n\nMake sure the MongoDB is accessible\nIf the MongoDB is running in a docker container, you could either use its [network](https://docs.docker.com/engine/reference/run/#network-settings) or expose the MongoDB port, the former is recommended. The example above uses the default network from the Wekan's docker-compose setup.\n\n## Other useful parameters\n\n- `MONGO_DIRECT_CONNECTION`: Don't try to connect to all replica nodes. Useful when you enable MongoDB replicaset to take advantage from Oplog, but the replica has been configured with an unreachable address (for example, `localhost:27017`). See [pymongo docs](https://pymongo.readthedocs.io/en/stable/api/pymongo/mongo_client.html#pymongo.mongo_client.MongoClient)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwekan%2Fwekan-cleanup","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwekan%2Fwekan-cleanup","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwekan%2Fwekan-cleanup/lists"}