Solution to Restore Recently Deleted Albums from iCloud Photos Library
Issue Description
During the Beta testing of the new iPadOS 26, I accidentally deleted all albums in my iCloud Photos Library on my iPad, which then synced the deletion to my other Apple devices. This resulted in the loss of all my photo albums, although the photos themselves remained intact in the “All Photos” section.
Solutions
1. Find the Deleted Albums in the Photos.sqlite Database
Find the Photos.sqlite database file in the Photos Library package. The path to the database file is as follows:
$HOME/Pictures/Photos Library.photoslibrary/database/Photos.sqlite
Use an SQLite database browser (such as SQLite3) to open the Photos.sqlite file:
SELECT Z_PK, ZUUID, ZTRASHEDSTATE, ZTRASHEDDATE, ZTITLE
FROM ZGENERICALBUM
WHERE ZTRASHEDSTATE != 0
OR ZTRASHEDDATE IS NOT NULL
ORDER BY ZTRASHEDDATE DESC;
It will return a list of deleted albums like this:
1234|D3F766E9-CD31-4F3C-935E-4D07E38BA11B|1|772405199.506|NieR
-
Field Descriptions:
Field Type Description Z_PKSTRING Primary key ID, used for subsequent updates ZUUIDSTRING Unique identifier of the album ZTITLESTRING Album name (if available) ZTRASHEDDATEREAL Timestamp when the album or photo was moved to “Recently Deleted” (Core Data time format, which is the seconds elapsed since 2001-01-01) ZTRASHEDSTATEINTEGER 0 = Not deleted, 1 or other values = Marked as deleted -
To convert the
ZTRASHEDDATEto a human-readable date, you can use the following command in the terminal:date -r $((978307200 + 772405199)) +"%Y-%m-%d %H:%M:%S"or use Python:
import datetime base = datetime.datetime(2001, 1, 1) delta = datetime.timedelta(seconds=772405199) print(base + delta)
2. Restore the Deleted Albums
-- Restore deleted state
UPDATE ZGENERICALBUM SET ZTRASHEDSTATE = 0 WHERE ZTRASHEDSTATE != 0;
-- Clear trash bin timestamp
UPDATE ZGENERICALBUM SET ZTRASHEDDATE = NULL WHERE ZTRASHEDDATE IS NOT NULL;
After executing the above SQL commands, the deleted albums should reappear in the Photos app on the devices after a restart or re-sync.
GUI SQLite Browser Alternatives
-
DB Browser for SQLite Install via Homebrew:
brew install --cask db-browser-for-sqlite -
TablePlus Install via Homebrew:
brew install --cask tableplusSupports multiple databases with a modern interface. The trial version is sufficient for viewing and editing SQLite databases for daily use.