May 4, 2021 ~1 minute minutes read Admin

Mbsync push

I foolishly copied my .mbsyncrc to my new laptop before copying the .mail folder. The result was that mbsync deleted all the mail on my IMAP server.

So I had to push everything back from the .mail folder on my old laptop. Fortunately, there's a good online guide here

The trick is to reset the local .mail folder by deleting all previous mbsync information.

remove all .mbsyncstate and .uidvalidity files:

find . -type f -name '.??*' -delete

Then remove the mbsyc identifiers from the mail file names:

find . -type f -name '*U=*' | { while read f; do mv "$f" "`echo $f | sed -e 's/,U=[0-9]*//'`"; done }

I then deleted all the folders on my IMAP server and restored them with an mbsync push.