# Is it possible to back up generated previews?

**URL:** <https://help.nextcloud.com/t/is-it-possible-to-back-up-generated-previews/183576>\
**Category:** ℹ️ Support\
**Tags:** photos-app\
**Created:** [February 28, 2024, 9:08pm UTC](https://help.nextcloud.com/t/is-it-possible-to-back-up-generated-previews/183576 "2024-02-28T21:08:19Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![ernolf](https://help.nextcloud.com/user_avatar/help.nextcloud.com/ernolf/32/77874_2.png) [@ernolf](https://help.nextcloud.com/u/ernolf)\
**Post date:** [February 28, 2024, 10:32pm UTC](https://help.nextcloud.com/t/is-it-possible-to-back-up-generated-previews/183576/3 "2024-02-28T22:32:30Z")

</div>

> [@MondQ](#):
>
> Is it possible to back those generated previews up in some way

Therefore you must understand the mechanism used to store those previews.

The previews are located in your data directory:

- _`"data/appdata_` **$instanceid** `/preview/*`_

First you should know that each file added to the nextcloud file cache receives its unique **file\_id**.

Since the loading of directories with many files takes a long time and requires a lot of resources each time a contained file is opened, a mechanism is used for things like this where many files are created, that ensures that the (preview) files are distributed across many small, evenly distributed directories.  
For this performance reasons, these are created in a hex tree. This hex tree has a directory depth of 7, which is created with the first 7 digits of the md5 hash of the file\_id.

Let’s take a file with file ID 1234 as an example. The 128 bit long 32 digit hexadecimal number of the md-5 sum is then _`81dc9bdb52d04dc20036dbd8313ed055`_

so this file path is then created (with the first 7 digits): _`8/1/d/c/9/b/d`_

and because this type of path assignment represents a pseudo-random distribution with 268,435,456 different folder paths, which ensures a good, balanced distribution of the tree, it is at risk of collision. But because the file\_id is also appended to this path as a folder, the path is absolutely uniq and a large, evenly distributed tree is possible with relatively short paths.

So the previews of the image with the file\_id 1234 will be located inside of this folder:

- _`"data/appdata_` **$instanceid** `/preview/8/1/d/c/9/b/d/1234`_

As you can easily see here, the entire path is no longer valid as soon as the images get a different file ID.  
But when making a backup, you should definitely save all files together. That means files, database and appdata folder.  
Then the preview images will also be retained.

This app does the generation of the hex tree before you open the file the first time.

| | |
| --- | --- |
| App-Id | previewgenerator |
| App-Name | Preview Generator |
| Summary | A preview pre-generation app |
| Categories | multimedia |
| App-Version | 5.4.0 |
| Repository | [GitHub - nextcloud/previewgenerator: Nextcloud app to do preview generation in the background.](https://github.com/nextcloud/previewgenerator) |
| Issue-Tracker | [Issues · nextcloud/previewgenerator · GitHub](https://github.com/nextcloud/previewgenerator/issues) |
| PHP min/max | 8.0 / 8.3 |
| NC min/max | 26 / 28 |
| | Not-shipped (not included) App available in appstore |
| Appstore | [Preview Generator - Apps - App Store - Nextcloud](https://apps.nextcloud.com/apps/previewgenerator) |

* * *

another posibility is to use [imaginay](https://github.com/h2non/imaginary) for the preview generation. You can run it as a docker image like Nexctloud AIO does.

* * *

Much and good luck,  
ernolf

---

_[View the full topic](https://help.nextcloud.com/t/is-it-possible-to-back-up-generated-previews/183576)._
