Skip to content

Use local time for local-backup snapshot folder names - #14911

Open
patjackson52 wants to merge 1 commit into
signalapp:mainfrom
patjackson52:local-backup-folder-local-time
Open

patjackson52 wants to merge 1 commit into
signalapp:mainfrom
patjackson52:local-backup-folder-local-time

Conversation

@patjackson52

@patjackson52 patjackson52 commented Aug 3, 2026

Copy link
Copy Markdown

First time contributor checklist

Contributor checklist

  • Pixel 10 Pro, Android 17 (playStagingSpinner) — on-device backup run against this branch and against main
  • Robolectric: ArchiveFileSystemTest, 14/14
  • My contribution is fully baked and ready to be merged as is
  • I ensure that all the open issues my contribution fixes are mentioned in the commit message of my first commit using the Fixes #1234 syntax

Description

Fixes #14866.

Snapshot directories for on-device backups are stamped in UTC, so a backup taken at 11:55 local shows up as signal-backup-2026-08-03-18-55-33. The reporter noticed this is a change from the v1 .backup files, which used local time.

This appears to be the only place in the app that stamps a filename in UTC. Android's v1 backups both write and parse in device-local time (LocalBackupJob / LocalBackupJobApi29, and BackupUtil.getBackupTimestamp, none of which set an explicit zone), and iOS's local backups do the same — LocalFileBackupManager.Constants.dateFormatter sets no timeZone, so it uses TimeZone.current. That's what led me to read v2's UTC as unintentional. If it was deliberate, I'm happy to close this and instead look at displaying local time wherever these names surface to users — just say the word.

Two changes:

  • createSnapshot() names new snapshots in the device's local time zone.
  • listSnapshots() no longer derives ordering from names. Directories written before this change carry UTC names, and nothing in a name distinguishes the two generations, so parsing a mixed directory with one rule orders an older snapshot ahead of a newer one by the local UTC offset. That ordering drives deleteOldBackups() retention, and RestoreLocalBackupViewModel renders SnapshotInfo.timestamp as the date label when picking a backup to restore, so a legacy directory written at 8pm local would also display under the following day's date. It now uses the directory's last-modified time, falling back to the parsed name only when a provider reports no modified time.

Renaming in either direction has the mixed-generation problem, which is why ordering moves off names rather than trying to parse both formats.

Testing

Built this branch and main onto a Pixel 10 Pro and ran an on-device backup with each, ~9 minutes apart in America/Los_Angeles:

signal-backup-2026-08-03-12-04-35   <- this branch, phone clock read 12:04 PDT
signal-backup-2026-08-03-18-55-33   <- main,        phone clock read 11:55 PDT

That pair is also what the new ordering test reconstructs: a mixed UTC/local directory asserting the newer snapshot sorts first, which fails without the listSnapshots() change. Also added a round-trip test pinned to a non-UTC zone (fails if either the write or parse side alone reverts to UTC) and a test for the name-parsing fallback. ArchiveFileSystemTest passes 14/14.

Unrelated observation

iOS writes signal-backups-<date> (plural) while Android writes signal-backup-<date> (singular), and the iOS doc comment documents the singular form. Android's prefix filter matches both by accident. Not touching it here, but flagging it in case local backup directories are meant to be portable between platforms.

@patjackson52 patjackson52 mentioned this pull request Aug 3, 2026
3 tasks
Snapshot directories were stamped in UTC, so a backup taken at 11:55
local appeared as signal-backup-2026-08-03-18-55-33. Android's v1
backups name and parse in device-local time, as do iOS local backups,
making this the only place in the app that stamps a filename in UTC.

Name new snapshots in local time, and stop deriving ordering from names
altogether: directories written before this change carry UTC names, and
a single parse rule cannot tell the two generations apart, so a mixed
directory could order an older snapshot ahead of a newer one by the
local UTC offset -- affecting both retention and the dates shown when
picking a backup to restore. listSnapshots() now uses the directory's
last-modified time, falling back to the parsed name only when no
modified time is reported.

Fixes signalapp#14866
@patjackson52
patjackson52 force-pushed the local-backup-folder-local-time branch from b188a8c to c9230e2 Compare August 3, 2026 19:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Backup timestamp in UTC

1 participant