How to make Time Machine Only Backup Emails? I know Time Machine is a great backup system on Mac, but I don't like it when it starts backing up everything on a mac.My work is completely done on emails and these emails now need to be backed up as the mailbox is filling up quickly. I am using Apple Mail as well as Outlook 2016 for Mac, both with different email ids. I need to backup both of them so that I don't lose any emails and also if I need to access those emails in future I can do that easily. Here Time machine is a great app to backup but I don't want to backup other stuff, I just need it to backup my email database. Is that possible, if yes then how can I do that and if no then what are other possible options I have as an email backup system?
The basics

First of all, I would highly suggest backing up your entire Mac with Time Machine. (It'll include all your emails that aren't on the server.) After the first backup it only saves what changed, so if you don't change anything outside of mail, it won't have to spend time re-backing it all up.

That said, you can back up just emails. I don't know how to do this with Time Machine (although it's probably possible), but it's relatively easy to do with a tool called rsync. Your emails are stored here (assuming you're using the built-in Mail.app):

~/Library/Mail

To back them up, you can just copy (not move!) this folder to an external drive. Unlike a Finder copy (as far as I know), rsync is smart enough to only copy the changes next time you back it up. To do one backup, run this command in the Terminal:

rsync -rlptgDEHP ~/Library/Mail /Volumes/"Some External Drive"/"Mail Backups"


This will copy the folder to a folder called "Mail Backups" on your external drive. (The quotes are required if you have spaces in the folder/drive name.)



Automating this with launchd

There's a program called launchd that, in addition to running basically the entire system (it's the Mac equivalent of init), can run other programs at specified times. To tell it what to run when, you use a plist file (short for "property list").

So how do you do this? You'll need to put this into a plain-text file somewhere, like ~/bin/backup-emails:

#!/bin/zsh

# lines starting with '#' are a comment and have no effect
# (except for the #! line above); you can leave them out

# this is the rsync command from the section above
rsync -rlptgDEHP ~/Library/Mail /Volumes/"Some External Drive"/"Mail Backups"


Then open a terminal, type chmod +x and a space, and drag in the file you just created. Hit Enter. This will make the file "executable" -- the system will be able to run it as a program.

You can run the file you just made instead of typing the rsync command when you want to back up manually.

Next, fire up TextEdit (or another plain-text editor of your choice) and paste in the following:

&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
    &lt;dict&gt;
        &lt;key&gt;Label&lt;/key&gt;
        &lt;string&gt;com.yourname.backup-emails&lt;/string&gt;

        &lt;key&gt;Program&lt;/key&gt;
        &lt;string&gt;/bin/zsh&lt;/string&gt;

        &lt;key&gt;ProgramArguments&lt;/key&gt;
        &lt;array&gt;
            &lt;string&gt;-f&lt;/string&gt;
            &lt;string&gt;-c&lt;/string&gt;
            &lt;!-- wherever you put the script you made before --&gt;
            &lt;string&gt;~/bin/backup-emails&lt;/string&gt;
        &lt;/array&gt;

        &lt;key&gt;StartCalendarInterval&lt;/key&gt;
        &lt;array&gt;
            &lt;dict&gt;
                &lt;!-- run every week at 7am --&gt;
                &lt;key&gt;Hour&lt;/key&gt;
                &lt;integer&gt;7&lt;/integer&gt;
                &lt;key&gt;Weekday&lt;/key&gt;
                &lt;integer&gt;0&lt;/integer&gt;
            &lt;/dict&gt;
        &lt;/array&gt;

        &lt;!-- replace your username appropriately --&gt;
        &lt;key&gt;StandardOutPath&lt;/key&gt;
        &lt;string&gt;/Users/username/tmp/backup-emails-stdout.log&lt;/string&gt;
        &lt;key&gt;StandardErrorPath&lt;/key&gt;
        &lt;string&gt;/Users/username/tmp/backup-emails-stderr.log&lt;/string&gt;

        &lt;key&gt;Debug&lt;/key&gt;
        &lt;true /&gt;
    &lt;/dict&gt;
&lt;/plist&gt;


Everything between &lt;!-- and --&gt; is a comment and can be left out. (This includes the comment markers themselves, of course.) Replace yourname with your name (if you want to), and username with your username (the name of your home folder; this is required).

(You can run man launchd.plist in a terminal to learn more about what you can do with these plist files.)

Save this file as ~/Library/LaunchAgents/com.yourname.backup-emails.plist (replacing the com.yourname.backup-emails with whatever you used in the Label key above).

This step isn't strictly required, but it'll load it without having to log out and back in:

launchctl load ~/Library/LaunchAgents/com.yourname.backup-emails.plist




Uninstalling the launch agent

Simply trash the ~/Library/LaunchAgents/com.yourname.backup-emails file you made before. (To get to it, press ⇧⌘G in Finder and type/paste in ~/Library/LaunchAgents.)