On Monday, 29 December 2025 16:16:23 Greenwich Mean Time [email protected] wrote: > Greetings, > A few day ago I made a very stupid mistake which caused complete loss of all > my emails, history and all. > > My ISP offers only POP3 access, but KMail has a poor record with that so I > have a mail server here which fetches mail every five minutes and uses > postfix and dovecot to serve it via IMAP4 to my desktop machine. The server > also runs a cron job every minute to rsync my user's .maildir to > /mnt/mailbu. I have accounts on both machines with the same name.) Thus I > have a complete record of all emails ever sent or received. Now the hard > part. > > I copied the mailbu back onto .maildir, then started KMail, which shows a > paltry 230 messages. I'm therefore left with importing from mailbu. My > questions: will that result in all mails being stored on the desktop > machine, and if so will I be able to re-export them to my IMAP server? > > Or perhaps it's time to simplify the whole setup and keep the whole email > operation on the desktop machine. > > I had a similar problem a few years ago, but that time I was able just to > copy mailbu to .maildir with no loss of mails; just much deleting of old > ones.
I am not clear on your exact architecture and where the message loss occurred.
Considering a Kmail client approach you can use IMAP4 to download your
messages from the server to the client, but large numbers of messages on
multiple accounts will take time. It is easier if you copy over the whole
maildir backup from the server filesystem directly to the client PC, then re-
index the akonadi SQL database:
Close kmail, stop the akonadi back end:
akonadictl stop
copy your messages from the server storage/backup to the corresponding
.maildir/{cur,new,tmp} subdirectories on your user's home on your desktop.
Disconnect the NIC and finally restart akonadi, it will crunch through the
message storage and with some patience it will re-index all your messages.
If it doesn't reindex them correctly, you can right click on your top imap
folder within Kmail, typically this is the Inbox folder for each account and
navigate to Folder Properties > Maintenance, then click "Reindex folder".
The incantations of:
akonadictl fsck
and
akonadictl vacuum
could help fix any SQL re-indexing glitch, should one occur. If the Kmail GUI
is not showing all expected messages, you can shut it down, shutdown akonadi
and restart Kmail. This will normally refresh Kmail's list of messages, but
with large numbers of accounts/folders/messages you have to be patient for the
whole process to complete before you start interfering with it.
Once it's done you can reconnect the PC to the network, so it can continue to
sync with your mail server and can fetch newer messages. The IMAP4 protocol
allows bidirectional data synchronisation, as long as you have enabled both
local and remote subscriptions on Kmail accounts. Therefore any changes you
make in your Kmail folders will be reflected on the server storage too once
the client has sync'ed with the server. I have used this method to move
messages between different servers as part of account migration. Moving only
a few hundred messages at a time so as to not overload the remote server and
cause the mail ISP to throttle my connection, has worked flawlessly here many
a time.
Separating the server operation from the client PC, whether this is physical
or virtual separation, has its benefits and disbenefits. Virtual separation
reduces the hardware and running costs, but the workflow will not change
materially. Only you can tell what benefits you think such a simplification
could bring, given the capital outlay for the server is already a sunk cost.
HTH.
signature.asc
Description: This is a digitally signed message part.

