Wrong directory for previewcleanup cron job
-
Hello @tobiasb
Thanks for reporting.
In addition to this, I also think that preview images should not really be in/app/data/.
They are not really worth being included in the backup since they can be regenerated at any time.
With the new Cloudron versions there is now persistentDirs so we should move them outside of/app/data/. -
Hello @tobiasb
Thanks for reporting.
In addition to this, I also think that preview images should not really be in/app/data/.
They are not really worth being included in the backup since they can be regenerated at any time.
With the new Cloudron versions there is now persistentDirs so we should move them outside of/app/data/.In addition to this, I also think that preview images should not really be in
/app/data/.
They are not really worth being included in the backup since they can be regenerated at any time.
With the new Cloudron versions there is now persistentDirs so we should move them outside of/app/data/.Yes please! NC previews can be a nightmare with rsync backups because it adds so many small files.
-
@james that update took down one of my Nextcloud instances. It was offline for 6 hours, stuck at
==> Resetting previews. There are maybe 300GB of images on that instance and it never managed to finish the cleanup (I think), only after I manually created/var/lib/nextcloud/previewit would come back up again. Not sure if the cleanup script was done that very minute or if there was an issue regarding that directory. -
Hello @msbt
Is your Nextcloud on an HDD or maybe a mounted network volume (NFS, CIFS)?
It could be that because of a slow disk this really did take this long.I did some measurements, inspected Nextcloud code, and issues.
There are many issues on GitHub complaining about image previews https://github.com/nextcloud/server/issues?q=is%3Aissue+state%3Aopen+preview+empty+foldersBy default, Nextcloud creates 4x image previews for each image.
At an assumed 3-5 MB per photo, 300 GB is roughly 60k-100k images. The file size is an assumption.
That means roughly 240k-400k preview rows and files, and about 55-95 GB of previews.Rows? Yes, Nextcloud stores each preview file in the
oc_previewsPostgreSQL table.
And the command that we currently use in thestart.shis$occ preview:cleanup.
This command goes through every preview image synchronously, one by one, deletes the file and then the row inoc_previews.Then there is another issue that empty preview folders are never cleaned up by Nextcloud.
We already did implement the cron that this topic is about that cleans up these empty folders.
Also, multiple GitHub issues dating back to 2024 and still this was never fixed upstream.That
$occ preview:cleanupis working synchronously is in my opinion extremely inefficient.
The command is for deleting all preview images, so why do it one by one?
If the command is for deleting all, why not simply delete all at once and truncate theoc_previewstable?
I don't know why they don't do it that way.I will create an update for the Nextcloud app that moves this process outside the
start.shso the Nextcloud can start and that clean-up will be done in the background and if my idea of delete all at once and truncate theoc_previewsis faster and does not cause issues will use that instead of the slow$occ preview:cleanup. -
Hello @msbt
Is your Nextcloud on an HDD or maybe a mounted network volume (NFS, CIFS)?
It could be that because of a slow disk this really did take this long.I did some measurements, inspected Nextcloud code, and issues.
There are many issues on GitHub complaining about image previews https://github.com/nextcloud/server/issues?q=is%3Aissue+state%3Aopen+preview+empty+foldersBy default, Nextcloud creates 4x image previews for each image.
At an assumed 3-5 MB per photo, 300 GB is roughly 60k-100k images. The file size is an assumption.
That means roughly 240k-400k preview rows and files, and about 55-95 GB of previews.Rows? Yes, Nextcloud stores each preview file in the
oc_previewsPostgreSQL table.
And the command that we currently use in thestart.shis$occ preview:cleanup.
This command goes through every preview image synchronously, one by one, deletes the file and then the row inoc_previews.Then there is another issue that empty preview folders are never cleaned up by Nextcloud.
We already did implement the cron that this topic is about that cleans up these empty folders.
Also, multiple GitHub issues dating back to 2024 and still this was never fixed upstream.That
$occ preview:cleanupis working synchronously is in my opinion extremely inefficient.
The command is for deleting all preview images, so why do it one by one?
If the command is for deleting all, why not simply delete all at once and truncate theoc_previewstable?
I don't know why they don't do it that way.I will create an update for the Nextcloud app that moves this process outside the
start.shso the Nextcloud can start and that clean-up will be done in the background and if my idea of delete all at once and truncate theoc_previewsis faster and does not cause issues will use that instead of the slow$occ preview:cleanup.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login