1

At the moment i do a simple Mail-Backup: On the server there is a Maildir, and i use rsync to sync the Maildir from server to backup.

So i delete on the Server every file which is older than i.e. one month. So i have only the latest mails on the server and the rest in the Backup only. So i do not use much space on the server, and if somebody hacks me, he will get only a month of mails instead of the whole archive.

the commands i use are:

rsync -avz Maildir/ backupserver:backup/Mails/
cd Maildir
touch -d 2011-07-30 dummy
find -type f \! -newer dummy -delete

That is working pretty good, but when i move a mail, which is already in the backup, i will have two copies of the mail in the backup. One copy from the old backup job, one from the new one. Or i may even decide to delete the mail and it will not be deleted in the backup.

I could use rsync with --delete, but then i need to have the full archive on the server, because otherwise it will delete the old mails in the backup, too.

So now my question is: How can i sync the Mails in a way, that preserves moves and deletions?

allo
  • 1,620
  • 2
  • 22
  • 39
  • Only with manual work. The Message-ID in each mail should be unique. This gives you the possibility to keep track of every mail. But for my subjective opinion your type of "backup" is strange. – mailq Aug 30 '11 at 18:11
  • I don't think you can, because you want to preserve the mails that are deleted by the system on day 30 but delete the mails that are deleted manually on day 29. – tomjedrz Aug 30 '11 at 19:18
  • what is a good idea for having only the latest mails on the server and the rest in a backup? An alternative would be to move mails older than 30 days to backup. i.e. via rsync parameter for only including old mails and then deleting or by using some imap tool. But then i do not have the most recent mails in the backup. Of course i can find double-mails by message-id, which i will need to do with the current backupset some time. But then i need to re-decide for every mail which folder is the "correct" one. – allo Aug 30 '11 at 20:00

1 Answers1

0

Okay, i think i have found a solution:

Using Syncmaildir, i keep my E-Mails from the local maildir in sync with the remote maildir. When i want to delete old mails from the server, but not from the backup, i first sync a last time, which syncs added/deleted/moved mails, then i remove the mail-db from the local and the remote .smd/ folder and delete the old mails.

Steps in Detail:

  • sync mails with smd-pull
  • when removing old mails from the server:
    • sync a last time with smd-pull
    • delete the old mails with the find-cmdline.
    • delete .smd/profilename__Mail.db.txt* files locally/remotely
    • sync again, so the db gets rebuild for the remaining files, so moves/deletions can be detected.
  • sync mails as always
allo
  • 1,620
  • 2
  • 22
  • 39
  • maybe not even rebuilding the db, but just using mddiff to check which mails generate a "DELETE" command after the delete step, and removing the corrosponding lines from the .smd/profilename.db.txt file. – allo Dec 09 '11 at 09:21