You can use either cyr_dbtool or cvt_cyrusdb to get the text version - 
cyr_dbtool is much more powerful.

HOWEVER - in either case, you're looking at mailbox uniqueids in the .seen 
folder.  So you're going to need to find those our.  With new enough Cyrus, 
they will be in the mailboxes.db file.  With older cyrus, you're going to have 
to read them from the cyrus.header files in each mailbox.  3.4.3 might be late 
enough to have put the uniqueids into the mailboxes.db, I don't remember!  Of 
course - you can also use cyr_dbtool or cvt_cyrusdb to read the contents of 
mailboxes.db.

NOTE: work on copies of the files, not the original.

Bron.

On Tue, Jun 30, 2026, at 09:35, Jay Sekora wrote:
> Hi!  I have a user who accidentally marked all her mail as "read" and
> needs read state of her messages restored from backups.  At the same
> time, she also accidentally deleted a bunch of messages, but also has
> gotten lots of new mail since then.
> 
> So I think what I need to do is restore her old inbox as of just before
> this happened to a new folder location (that part is easy), and then get
>  a copy of her $username.seen file from the same backup, extract the
> seen/unseen data from the .seen file, and apply seen/unseen state to
> the corresponding messages in the new (restored) folder location.
> 
> So the two pieces of this that I don't know how to do are (1) dumping
> the twoskip file to a text format that I can get the seen/unseen message
> UIDs out of, and (2) correlating the folder IDs in the twoskip file with
> folder names I can select in `cyradm`.  (If there's an easier way to do
> this I'd love to hear it!)
> 
> So, (1) is there a script available somewhere to dump twoskip files to
>  a text format?  And (2) how can I get a list of folder names and
> corresponding folder IDs as found (apparently) in the twoskip file?
> (2) seems like something I ought to know, but I don't. :-)
> 
> (Running `strings` on the twoskip file suggests the folders are stored
> as IDs like "xhz89kuj0c4m8w0ey4tafenk1" rather than folder names like
> "user.so-and-so".  But presumably the output of `strings` might include
>  values that are deleted or superceded, and in any case it looks like
> the actual message UIDs are in binary rather than textual format in
> the twoskip file.)
> 
> Jay
> 
> PS -- This is on Ubuntu 22.04 with Cyrus 3.4.3 as packaged by Ubuntu.
> But I can't imagine the package maintainers broke the twoskip file
> format. :-)
> 
> PPS -- I found
> https://github.com/cyrusimap/cyrus-imapd/blob/master/lib/cyrusdb_twoskip.c
> but my C is pretty rusty and I don't feel confident trying to convert that
> to perl or python or something on my own.  The other way I've thought
> of to do this is to bring up an entire second IMAP server, restore the
>  user's inbox and .seen file to it as of a consistent date, and use
> `imapsync` to synchronize seen/unseen state from the restore with the
> production IMAP server — assuming the folder ID is actually stored
> *in* the folder directory itself.  That sounds even worse than trying
> to parse the twoskip file.

--
  Bron Gondwana, CEO, Fastmail Pty Ltd / Fastmail US LLC
  [email protected]


------------------------------------------
Cyrus: Info
Permalink: 
https://cyrus.topicbox.com/groups/info/T643419685ae5113c-M57ae47210c17b347367077c5
Delivery options: https://cyrus.topicbox.com/groups/info/subscription

Reply via email to