Immich user deletion: all or part
Immich user removal operates on the metadata layer; the CLI uses --uuid to identify accounts. This note documents the commands for single and bulk deletion, associated risks, and safe alternatives for self-hosted instances.
Preparation and deletion commands
Before removing an account, verify the Immich container is running and the CLI is accessible. In a typical self-hosted Linux setup, user management is available from inside the container via docker exec or from the host if the CLI is configured to connect to the database.
The primary flag recurring across all scenarios is --uuid. The user identifier can be obtained from the web interface by clicking the profile, or by querying the list above. A common error at this stage is attempting deletion without the UUID, resulting in an “invalid user id” error.
Deleting a user via CLI does not remove the media files from disk, but it clears bindings and access permissions. Take a database backup before any large‑scale operation.
Deleting a specific user
Single account deletion uses one command. The syntax follows the Lead DevOps style: minimal flags, clear result.
After execution, Immich marks the user as deleted, detaches their albums, and frees license slots (in self-hosted setups with user limits). Media files uploaded by that user remain in storage but are no longer displayed in the general view unless albums are explicitly removed.
If the album itself must be deleted along with its files, use the album command:
Table of key flags for the single‑user deletion scenario:
| Flag | Purpose | Example |
|---|---|---|
--uuid | User or album identifier | --uuid 123e4567-e89b-12d3-a456-426614174000 |
--output | Output format for scripts | --output json |
| Command | Description |
|---|---|
immich user list | Show all users with UUIDs |
immich user delete --uuid <id> | Delete user, preserve media |
immich album delete --uuid <id> | Fully delete album and files |
Bulk deletion of all users
Immich does not provide a single flag to delete all users. The cleanup of the entire database requires a scripted wrapper. A common approach on Linux: collect UUIDs, iterate through the list, and execute deletion.
Example bash script:
Before running such a script in a production environment, test it on a staging instance. Bulk deletion breaks links in shared albums, revokes access to common libraries, and may cause PostgreSQL integrity errors if users have attached metadata.
| Risk | Consequence |
|---|---|
| Deleting the system user | Broken connections, container startup errors |
| Skipping dependencies | Corrupted albums, lost shared‑access settings |
Data security and alternatives to rm -rf
Avoid direct file or database deletion with rm -rf or docker volume rm without understanding Immich’s structure. Production installs use PostgreSQL for metadata, while original photos and videos reside in the configured DATA_DIR. Wiping the database without a rollback leads to irreversible loss of album history, comments, and privacy settings.
Safe alternatives that respect Immich’s functional boundaries:
- Use the CLI —
immich user deleteandimmich album deleteguaranteedly update indexes and references. - Disable the account — change the password or block access via the admin UI, leaving data intact.
- Create a backup —
pg_dumpthe Immich database before any user‑related changes. In compose configurations this can be automated via abackupservice.
Table comparing approaches to data cleanup:
| Method | Safety | Restorability | Recommendation |
|---|---|---|---|
immich user delete --uuid | High (updates indexes) | Full (via backup) | Operational scenario |
rm -rf /immich/data | Low | None | Forbidden in production |
docker volume rm immich_db | Medium | Partial (depends on snapshots) | Only during reinstallation |
| Setting | Action |
|---|---|
IMMICH_BACKUP_ENABLED=true | Automatic snapshots of the database before user deletion |
IMMICH_DATA_DIR | Verify the path is correct before mass album deletion |
Automation via scripts and compose
For regular maintenance of a self‑hosted Immich infrastructure, wrapping deletion operations in scripts scheduled or triggered as needed is practical. Example Docker‑compose addition of a one‑shot service:
After updating the config, verify with docker compose config to catch syntax errors. Following script execution, a useful check is:
This confirms the user count has decreased or the list is cleared. Automation frees administrators from routine tasks, but strict UUID list control is essential; otherwise the risk of removing necessary accounts remains high.