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

Store Mail folders and prefs on a secure disk image Apps
Use the following solution to securely encrypt and keep backups of your mail folders and preferences (along with any other important documents - I keep all of my office and personal documents this way as well.)

  • Using Disk Copy, create a New Blank Image of custom size (I made mine 300mb, but you can always copy the files to a new bigger image later), format Mac OS Extended, encryption AES-128. Name it SecureDisk or something and stash it somewhere you'll remember it. In my case, its in ~/Documents/SecureDisk.dmg. First, we'll copy the Mail data folders...

    1. Make sure Mail.app isn't running and SecureDisk is mounted on your desktop.
    2. Using the finder, navigate to ~/Library (Apple-N, click the Home button, open Library)
    3. Copy the Mail folder into SecureDisk
    4. Move ~/Library/Mail to the trash
    5. Open up a terminal window and enter the following commands:
        % cd ~/Library
        % ln -s /Volumes/SecureDisk/Mail .
      The ln -s command makes a UNIX link (basically the same as an alias) pointing from your ~/Library folder, where Mail.app will normally look for all of its files, out to the secure disk, where you'll be keeping them from now on. For some reason, making a standard MacOS alias won't work here - you need to use the terminal.


  • Now we'll do the same thing with the mail preferences, so those are saved too:

    1. Using the finder, navigate to ~/Library/Preferences (Apple-N, click the Home button, open Library, open Preferences)
    2. Copy com.apple.mail.plist from the Preferences folder into SecureDisk/Mail
    3. Move the original from com.apple.mail.plist to the trash
    4. Then, again opening a terminal window:
        % cd ~/Library/Preferences
        % ln -s /Volumes/SecureDisk/Mail/com.apple.mail.plist .
      Again, ln -s works, but making a normal alias doesn't.

  • Last but not least, we'll copy Mail.app into the disk too:

    1. Using the finder, find Mail.app (probably in /Applications) and copy that into the top level of SecureDisk.
    2. Move the old copy to the trash
    3. If you have Mail.app in your dock, pull it out, then drag the newly-moved one to the dock in its place.The reason for doing this is, if SecureDisk isn't mounted when you go to start Mail, the finder will be smart enough to mount the disk first (if the folders are on the disk image, but the application isn't, Mail will start but will be very confused...)
Eject SecureDisk from your desktop, click on the Mail icon in your dock, and everything should start up as it always does, only this time it will first ask for the encryption password and mount the SecureDisk disk image! If it doesn't, just go back into the trash and put everything back where it was before.

Once a week or so, I start up Disk Copy, choose File/Convert (Apple-K), open the SecureDisk.dmg file, save it with image format compressed, encryption AES-128, name it SecureDiskBackup.dmg, and then use the Finder's File -> Get Info (Apple-I) to set it Locked. Someday soon I'll make a script to automate that backup process - any kind souls with more AppleScripting experience want to paste the code here? Burn the backup to CD, copy it to another drive, whatever suits you, and you now have any important documents encrypted, backed up, etc!

Enjoy!

[robg adds: Though I haven't tried this, one caveat to keep in mind is that if a system update tries to update Mail, it may not work (as it won't find it /Applications). I'd recommend putting the application back in /Applications prior to running any updates.]

    •    
  • Currently 3.67 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (3 votes cast)
 
[20,771 views]  

Store Mail folders and prefs on a secure disk image | 10 comments | Create New Account
Click here to return to the 'Store Mail folders and prefs on a secure disk image' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Store Mail folders and prefs on a secure disk image
Authored by: leffo on Apr 17, '03 10:55:35AM

This is a very, very cool hint. Thank you.



[ Reply to This | # ]
Store Mail folders and prefs on a secure disk image
Authored by: mclbruce on Apr 17, '03 12:33:56PM

I think removing mail.app from the applications folder is not something to do lightly. There several ways to work around that

Write a little applescript to open mail.app and put that in the secure disk. Make an alias of it and keep the alias on your desktop.

Write an applescript that selects and opens a folder on the secure disk, closes the folder, then opens Mail.

It's a neat trick. The abiltity to mount a disk at a specific place in the file structure is a great.



[ Reply to This | # ]
another method
Authored by: gelstudios on Apr 17, '03 02:11:36PM

you can set a mail directory in the mail preferences, its under the advanced tab of your account settings panel.



[ Reply to This | # ]
Store Mail folders and prefs on a secure disk image
Authored by: mwalles on Apr 17, '03 02:34:14PM

Another thing is that if you place the disk image on a server
somewhere, as soon as you click on the Mail icon in the Dock it
will try to mount the server partiton (if not mounted) and then
mount the disk image.

This is great for people like me that need to access mail on
more then one computer and cann't use imap to do it.



[ Reply to This | # ]
Quick Applescript to Mount Disk Image
Authored by: markd on Apr 17, '03 02:45:31PM
I'm no programmer, but I whipped this up to automate the processing of mounting the encrypted disk image prior to launching Mail. Please post corrections and/or improvements.

It would also be very cool to combine this hint with this one regarding sparse images that grow to fit.

set afile to "Users:markd:cryptonite.dmg"

tell application "Finder"
	if the disk "cryptonite" exists then
		return
	else
		do shell script ("hdiutil mount \"" & 
			POSIX path of (afile as string) & "\"")
	end if
end tell

tell application "Mail"
	launch
end tell


[ Reply to This | # ]
Quick Applescript to Mount Disk Image
Authored by: puffyn on Apr 18, '03 01:45:17AM
This is far from ideal/finished, but I wanted to automate the process a little more. I'm using the system to secure my Notes library, so anyone using this with Mail could just replace "Notes" with "Mail" in the appropriate places.

Basically the idea is to have a script which mounts the disk image and launches the program and then sticks around so that when the application is quit, the secure disk image is unmounted.

Save the following script as an application, and check the "Stay Open" box and the "Never Show Startup" box. You should call your application "CryptoNotes" or change the 6th line from the bottom to whatever you call it.

On run, the program runs the parent comments' script. It then pauses for a while before going into it's idle state, in which it checks whether the application in question is still open every 5 seconds (this is a very processor-friendly call, but you could increase this time interval if you really want to).

Then, when you quit Notes, CryptoNotes ejects the secure disk image, and quits itself (sometimes the second action occurs 5 seconds after the first). Your files are not left lying around unencrypted.

This works okay for me, but could be improved. The biggest kludge is the delay 10 in the on run section. This is to prevent the script from unmounting the disk image before Notes can open for the first time, but clearly if something caused Notes to take more than 10 seconds to open, this would fail.

on run
set diskpath to "Users:puffyn:Documents:SecureDisk.dmg"
set diskname to "SecureDisk"
tell application "Finder"
if the disk diskname exists then
return
else
do shell script ("hdiutil mount " &
POSIX path of (diskpath as string) & "")
end if
end tell
tell application "Notes"
launch
end tell
delay 10
end run
on idle
set diskname to "SecureDisk"
tell application "Finder"
if not (exists the disk diskname) then
return
else
set x to the name of every process
if "Notes" is not in x then
eject diskname
tell application "CryptoNotes" to quit
end if
end if
end tell
return 5
end idle


[ Reply to This | # ]

Quick Applescript to Mount Disk Image
Authored by: jmb on Apr 18, '03 08:23:00AM

You could set up a cron job to check if Notes i running and, if not, have it eject the image if present. I could imagine that this might create rare problems if, for instance, the cron job runs between disk mount and app launch, but doing it this way would make it independent of an AppleScript that might crash and not be running when needed.



[ Reply to This | # ]
Rather than copy Mail.app, try symlinking
Authored by: mj on Apr 17, '03 06:21:24PM

I don't care care for this kind of security, so I haven't tried this, but one alternative to having a copy of Mail.app on the disk image is to just symlink to Mail.app from the disk image. So, make a directory on the disk image called Mail.app, and inside it, symlink to the Contents directory in Mail.app. Opening this symlinked version treats it as a copy of Mail.app, so opening it will open a second Mail.app if the one in Applications is already running. I like this method, as a symlink is much smaller than the actual app, and updates should work more gracefully, without intervention.

MJ



[ Reply to This | # ]
Store Mail folders and prefs on a secure disk image
Authored by: crummel on Apr 18, '03 04:52:16AM

What I carry around with me in the same way as described with the Mail-folder are ~/LibraryCalendars/ and ~/ Library/Application Support/AddressBook/. This way I don't even need iSync...

But I found out that Mail is desperately relying on AddressBook to startup - if its AddressBook-data is missing (i.e. my memorystick not mounted), Mail won't start.

So it is a good idea to carry your data around with you, but you can't always start applications as you would like to.



[ Reply to This | # ]
PGP Disk or Encrypted Disk Image?
Authored by: drhfk on Apr 19, '03 01:20:21PM

What are your experiences with PGP Disks? Are they more or
less reliable than encrypted .dmg files? What are the pros and
cons? Thanks, drhfk



[ Reply to This | # ]