All posts

Remote Index Upgrade: V1 to V2

Design NotesPublished Updated @beimenjun

Open a Watermelon Backup directory and you'll see photos and videos organized by year and month. But filenames alone don't tell the app which still image and video belong to the same Live Photo or whether a file is already in the backup. Each month has a SQLite manifest that keeps track of items, their component files, and the files' hashes. By reading those manifests, Watermelon Backup can see what's stored and know which files to fetch without downloading all the originals first.

V1: The manifest lived beside the photos

The original layout was straightforward. Each monthly manifest went in that year's and month's folder. The June 2026 manifest, for example, was 2026/06/.watermelon_manifest.sqlite. To find every month in the backup, the app had to list the years and then look through their month folders for manifests. The more months the remote storage held, the more round trips that took. That was the overhead we wanted to reduce.

V2: A directory just for manifests

Watermelon Backup 1.5.0 introduced the V2 remote index format. The original files didn't move. The June manifest went to .watermelon/months/2026-06.sqlite. Now the app can list months once to see which months are present instead of going into every folder with photos. There's still one manifest per month, not one database for every year. On a routine sync, the app can reuse unchanged months and only read the manifests that need updating.

This release also added .watermelon/version.json, which records the remote backup format and the oldest app version that supports it. On Nodes that support remote write locks, the app gets a lock before writing so two devices don't update the same repository at once. The new layout answers two questions the old one didn't: which format should open this backup, and which device is allowed to write next?

To upgrade an existing backup, the app copies the SQLite manifests one month at a time. It reads them back, compares them with the originals, and checks that they open before committing the version marker. Photos and videos stay in their existing folders and don't have to be uploaded again. See the 1.5.0 migration code for the implementation.

After the upgrade, don't write to that backup with an app version older than 1.5.0. If you copy the whole backup elsewhere, take the hidden .watermelon directory along with the year and month folders. It contains manifests used for restores, not a cache you can discard.