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?
Solution 1:
You can work out with Time Machine to exclude all the other folders except your Apple Mail Database Folder and Your Outlook 2016 mac database folders. As you haven't mentioned which version of Apple Mail you are using so here is how you can find your Mail Database Folder:
Find and Open the Folder Where OS X Mail Stores Mail
To go to the folder that holds your OS X Mail messages:
Open a new window in OS X Finder.
Select Go | Go to Folder… from the menu.
You can also press Command-Shift-G.
Type "~/Library/Mail/V3".
Press Enter.
You can find your folders and messages in sub-folders to the V3 folder:
Local mailboxes are in the Mailboxes sub-folder.
POP email accounts can be found in sub-folders with POP- in their name.
IMAP accounts' mailboxes are in sub-folder that have IMAP- in their name.
The messages are stored in .mbox folders, one per OS X Mail email folder. Open and explore these folders to discover (and open or copy) the emails saved as .emlx files.
Find and Open the Folder Where Mac OS X Mail 5–8 Store Mail
To open the folder where Mac OS X Mail keeps your messages:
Open a Finder window.
Select Go | Go to Folder… from the menu.
Type "~/Library/Mail/V2".
You can have Finder auto-complete the folder names by pressing Tab.
Click OK.
Mac OS X Mail stores the mailboxes in sub-folders to the Mail directory, one sub-folder per account. POP accounts start with POP-, IMAP accounts with IMAP-.
Find and Open the Folder Where Mac OS X Mail 1-4 Store Mail
To locate the folder where Mac OS X Mail 1-4 stores mail:
Open a new Finder window.
Go to your home directory.
You can use the Home toolbar button or
select Go | Home from the menu to go home.
Open the Library/Mail directory.
Also there are multiple application available online for mac database backup as mentioned by Eric in the above post. There is one that is specifically for emails only and backs up all the email clients on Mac. Have a look: http://www.mailbackupx.com/how-to-scenerios/how-to-backup-apple-mac-mail-mails-o n-mac.html
Solution 2:
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:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.yourname.backup-emails</string>
<key>Program</key>
<string>/bin/zsh</string>
<key>ProgramArguments</key>
<array>
<string>-f</string>
<string>-c</string>
<!-- wherever you put the script you made before -->
<string>~/bin/backup-emails</string>
</array>
<key>StartCalendarInterval</key>
<array>
<dict>
<!-- run every week at 7am -->
<key>Hour</key>
<integer>7</integer>
<key>Weekday</key>
<integer>0</integer>
</dict>
</array>
<!-- replace your username appropriately -->
<key>StandardOutPath</key>
<string>/Users/username/tmp/backup-emails-stdout.log</string>
<key>StandardErrorPath</key>
<string>/Users/username/tmp/backup-emails-stderr.log</string>
<key>Debug</key>
<true />
</dict>
</plist>
Everything between <!--
and -->
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
.)