Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

10.4: A simple Mail backup Automator workflow Apps
There are lots of roads leading to Rome, and there a lots of ways to do the Mail backup task on OS X. A really simple and effective way is to let Automator do all the work. Here is how it's done. (You may wish to quit Mail before you start, just so it's not receiving new messages just as you're trying to create a new backup.)
  1. Start Automator
  2. Drag drop ~/Library » Preferences » and ~/Library » Mail into the Automator panel. This will automatically create an Automator action (Get Specified Finder Items) containing the two items you dropped.
  3. In Automator's Library column, go to Finder and choose Create Archive. Drag it to the work area on the right, below the existing command. Change the 'Save as' value to something other than archive, if you wish.
  4. In the Action column, drag Rename Finder Items into the work area, below the other two commands. By default, this will add a date and time stamp to the existing filename.
  5. Save the whole Automator workflow as a Program (you can choose this option in the Save dialog).
This workflow will create a file named in your Documents folder (unless you changed some of the settings) containing a zipped archive of your Mail folder and settings for the current user.

There are quite a lot of options you can modify to improve this workflow. For instance, you can choose a different archive name and location. The idea behind this simple workflow can be used to handle a lot of backup tasks -- i.e. doing a backup of the whole Delicious Library database. (For the first action, just drag and drop the directory ~/Library » Application Support » Delicious Library, and the file ~/Library » Preferences » com.delicious-monster.library.plist.)

[robg adds: To further automate things, you could use any of a variety of tools (iCal's ability to run an AppleScript as an alarm event; Cronnix; cron) to schedule your script to run each day at a given time. I've said it before, but Automator is really one of 10.4's hidden gems -- I learned even more about it on last week's MacMania Geek Cruise, and came away even more impressed with its capabilities.]
  • Currently 2.75 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (4 votes cast)

10.4: A simple Mail backup Automator workflow | 5 comments | Create New Account
Click here to return to the '10.4: A simple Mail backup Automator workflow' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
10.4: A simple Mail backup Automator workflow
Authored by: morespace54 on Jun 04, '07 04:04:46PM

Thanks for the tip!
Automator can be a such a time-saver sometimes...
Is there anyway to add every attachments in a folder within the archive?
I know everything should already be there but it would be so great to have attachments in a separate folder (even if it double the size of the archive). Most of the time, I just need to check something that was attached to some mail and don't want to "restore" the complete folder... Maybe that's a stupid question but still, that would save me sooo much time.
Thanks anyway.

[ Reply to This | # ]
10.4: A simple Mail backup Automator workflow
Authored by: craigst on Jun 05, '07 07:58:31AM

I tried creating this workflow but it didn't work. The error was in the Create Archive step. Said "[NSCFArray objectAtIndex:] index (4) beyond bounds (4) (-1) occurred in Creat Archive"

[ Reply to This | # ]
10.4: A simple Mail backup Automator workflow
Authored by: derekhed on Jun 05, '07 11:38:53AM

I too had this error. I rebuilt my script and selected the items to add to the archive one at a time instead of dragging the items from the Finder into the automator window. The script seemed to run fine after that.

[ Reply to This | # ]
10.4: A simple Mail backup Automator workflow
Authored by: mhite on Jun 25, '07 04:15:47PM

This happened to me also. To "fix" it, I removed the plist file from the archive file list (it was at the top), ran the Automator workflow again and suprisingly enough it worked. I added back the plist file, ran it again, and the problem didn't reappear. Go figure. I haven't the slightest idea why it nows works.

[ Reply to This | # ]
10.4: A simple Mail backup Automator workflow
Authored by: cooker47 on Jul 01, '07 12:53:15AM

A very useful example as I didn't know you could just drag objects like that to create the "Get Specified Finder Items" block.

I managed to get the thing working first time through, only to find that all of a sudden it then stopped working with a similar error code in one of the conversions - I'm not sure exactly what it was or what I did wrong - I had tried changing the word "archive" in the "Create Archive" step to "Mail-archive", and that's illegal [What other options can you put in there anyway? The field is editable.] - the problem started right after this - but also maybe I dragged the items in the "Get Specified Finder Items" step into a different order by mistake - [Thinks: can you do that?]

Anyhoo, I started over and added an extra "Rename" to call the result "" and it works fine.

Not to be pedantic, I found I couldn't "save it as a Program" [sic] but I could save it as an Application. However, I found mine wouldn't run while Automator itself was still going, but worked after I quit Automator, either because it still had the workflow open, or because you have to quit Automator to start a workflow that has been saved as an Application.


[ Reply to This | # ]