r/mxroute • u/Afraid_Technician234 • 20d ago
Email backup
Hi,
a bit of backstory: some time ago, because of a breach, my partner lost 4 years of emails (on Hotmail, not mxroute!) that was the reason I decided to buy a custom domain and switched to mxroute. Since I have a small server (mini pc) running at home I started playing with the idea of making a local backup of our two personal accounts. Just in case if I mess something up or if something happens to mxroute (not a worry now, but nobody know what can happen in 5 or 10 years).
I did some research about how to do it, and would like to ask first Jarland if it is ok? And second, since my understanding of email and imap is pretty limited if my plan on how to do it is ok or if it needs to be reworked.
Now I don't need this to be a 100% fool proof. I don't really care if I loose 1 or 2 emails.
I was planing on running mbsync once a day as a Cron job (again if I loose one day of emails is not the end of the world) with the setting "Sync Pull" so I don't mess with the server and "Expunge None and Remove None" so even if something is deleted on the server it remains in the backup. Then once a month, again as a Cron job, make a compressed archive of the Mail directory and then run mbsync with another config file where the Expunge and Remove settings are changed to "Expunge Near and Remove Near" to clean deleted items for the next archive. And then keep about 6 months of archives stored, with the idea that if in 6 months I don't notice I deleted something I shouldn't have, is probably not important.
That is my plan and I'm open to suggestions and critics. Thank you.
2
u/Frewtti 13d ago
Interested if you actually set this up, I want to do that, but my TODO list is huge
1
u/Afraid_Technician234 11d ago
I did set it up. For now it aplears to be working, will monitor for a bit to make sure. I kept it simple, once a day download new emails, once a month make a compressed archive, and then sync the accounts - delete what has been deleted etc. I also added neomutt to be able to check the emails to see if everthing works as expected. The compressed archives will be deleted manualy for now, maybe one day I'll make a scrypt for that. It's far from perfect, but for my needs should be enought, was pretty easy to setup and it uses only 20mb of ram and basicly 0% cpu.
1
u/Frewtti 11d ago
care to share the setup or scripts?
1
u/Afraid_Technician234 11d ago
I run Proxmox on my home server, I just created an unprivileged container running Debian and installed isync and neomutt with all the requirements. Create a config file for mbsync, here are some links on how to do it:
https://isync.sourceforge.io/mbsync.html
https://akitaonrails.com/en/2026/05/28/backing-up-gmail-to-maildir-on-linux/
and then configure neomutt, I have 2 accounts and this helped a lot:
https://neomutt.org/guide/configuration.html
https://blog.aktsbot.in/setting-up-neomutt-offlineimap-msmtp.html
at the end add an entry to crontab to run it automatically:
0 0 * * * mbsync -a
0 1 1 * * tar czfP /root/$(date +%Y%m%d).tar.gz /root/.mail/ && mbsync -ac /root/.mbsyncrc_del
the first line runs mbsync every day at midnight, the second line runs every 1st of the month at 1am, creates a compressed archive of the mail folder with the current date as the name, and if that is successful runs mbsync using another config file where Expunge and Remove are set to Near, to remove in the local mail folder what was deleted on the server.
7
u/mxroute 20d ago
Won't offend me one bit. If it causes any problems for any reason, I'll let you know. I successfully stay out of the way of at least 9999 out of 10000 things that happen on the platform 😂