Find and Delete Ghost Files in Nextcloud¶
Info
This guide was written by @jdaviescoates in post forum.cloudron.io/post/110118
Motivation¶
If you're seeing way more disk space used than expected in your Nextcloud app (33 GB used
but 177 GB occupied
etc.), here are some terminal commands you can run inside the app to identify and clean up ghost files, previews, app caches, and more.
You will need to open the Web Terminal of your Nextcloud app.
Or use the cloudron exec --tty --app $APPID
command to get an interactive shell in your local terminal.
Check Overall Disk Usage¶
du -sh /app/data
See how much disk space is used by Nextcloud's data directory.
List Folder Sizes in /app/data
¶
du -sh /app/data/* | sort -h
This shows usage per user/app folder so you can spot what's bloating.
Clean Common Space Hogs¶
1. Delete Preview Cache (safe to delete)¶
rm -rf /app/data/appdata_*/preview/*
You can regenerate them later as needed.
2. Delete Old File Versions & Deleted Files¶
occ versions:cleanup
occ trashbin:expire
occ trashbin:cleanup
If that doesn’t clear enough, nuke them manually:
rm -rf /app/data/*/files_versions/*
rm -rf /app/data/*/files_trashbin/*
3. Clear Unused App Data (e.g. SnappyMail)¶
Warning
Make sure your email is stored elsewhere (e.g. Cloudron mail server) before deleting.
If you’re not using the built-in SnappyMail app and use external email instead:
rm -rf /app/data/appdata_snappymail
Reindex Files After Cleanup¶
occ files:scan --all
This updates Nextcloud’s file index to reflect the actual files on disk.
Disable or Remove Unused Apps¶
If not using an app, stop it from consuming space:
occ app:disable snappymail
occ app:remove snappymail
Bonus: See Per-User File Usage¶
du -sh /app/data/*/files | sort -h
These steps helped me recover over 50 GB of space (from 142 GB → 87 GB) just by clearing previews and unused mail cache. Hopefully they help you too!
Let me know if you spot anything else that tends to grow quietly.