Just putting this up mainly for my own benefit, but if it helps you too – great!
This guide covers the following:
- Backing up your files
- Clean Install
- Restoring files, settings, passwords, etc
This guide is based on you having already upgraded to Yosemite – the reason I prefer this is because this lets your Mac do all the hard work of updating all of your files and settings to be Yosemite compatible. So if you haven’t upgraded to Yosemite, do that first and come back.
Ready? Ok – let’s get started!
What do you need to copy/back up first?
As we’re doing a clean install we’ll be re-installing all our programs from scratch, so the only thing we need (as well as of course the installers for our programs) is a copy of our home directory (I assume all your important files that you want backed up are already in it – if not back them up too).
Make sure hidden files are switched on first, in the terminal type:
We don’t want to restore files from the normal Time Machine backups as this can give you ACL and permissions problems – so you’ll want to copy the home folder onto a separate HD (if you only have a Time Machine disk, just make sure it has enough room for your entire home folder then drag it into the root – you can delete it afterwards).
One thing you should make a note of first is your email passwords – for some reason, Mail asks you to re-enter these even though you have copied your keychain over. It is easy enough to get the passwords tho, open Keychain (CMD Space and ‘Keychain’) then search for each email address and when found right click and ‘show password’.
Copy Yosemite installer to a USB drive
Download Yosemite from the app store, but quit the installer when it’s ready. Or, if you’ve already downloaded Yosemite and gone ahead and upgraded, simply go back to the app store, hold down alt and click on the ‘purchased’ tab at the top – the faded out ‘installed’ button for Yosemite will go and you’ll now have the ‘install’ option again, click it, but when it’s ready to install quit the installer.
Rename the USB drive to YosemiteInstaller, then in terminal type the following – just be aware that it will wipe the USB drive:
It might take a while but when it’s done you are ready to proceed.
Insert the USB disk and restart your Mac, but keep the ALT key held down and select the USB disk to boot up from.
Once it’s booted up:
- Go to Disk utilities from the menu
- Select the disk you want to install Yosemite to
- Click erase and give it a name
- If you want to securely delete what’s already on there choose the option in ‘security options’ (Not needed if your previous install was encrypted)
- Click ‘erase’
- Once done close window
- Back in the main options screen select Reinstall Mac OS X (fresh copy option)
Then follow the instructions to set it up. Use the same account name and password as your previous install – as that makes it easier when copying over your keychain, etc. When it asks you if you want to use iCloud – choose skip this step for now as it can mess with your Account password (Apple appear to want you to use you Apple username and password to access your machine!)
Turn on Firewall, install LittleSnitch and turn off wake from sleep for network activity
For some odd reason the Firewall isn’t on by default, so System Prefs > Security and Privacy.
Install LittleSnitch if you like to control network activity for your programs.
Then if you don’t want your Mac to wake from sleep because of network activity, turn it off via System prefs > energy saver > uncheck wake for network access
Putting everything back
Now that you’ve backed up all your important files and done a clean install, it’s time to put back all your important stuff, such as:
- Keychains & Passwords
- Address book & Contacts
- .ssh folder and other important invisible files
First, make sure hidden files are switched on, in the terminal type:
Then copy your backed up home folder to your new desktop – I’ll refer to this as the ‘old home folder’ from here on.
Simply move the ‘V2’ Mail folder from /.Library/Mail/from your old home folder, to /.Library/Mail/ on your new install. If you want to, you can rename the the original ‘V2’ folder to something like ‘V2-original’. Don’t open your Mail program until you’ve done the next step.
Hit Command and the Space bar to open spotlight, then type in ‘keychain’ and enter to open Keychain Access.
Navigate to the /.Library/Keychains folder on your old home folder and rename the login.keychain to something like old-login.keychain and then copy it to your new /.Library/Keychains folder.
In Keychain Access go to File > Add Keychain from the menu, then select the old-login keychain.
Now we want to copy everything from the old-login keychain into the new login one.
Normally when copying Keychain items from one to the other, Keychain Access will ask you for your password for every item – but that would be a huge pain in the butt!
Right click the old-login keychain and select set new password. Put in the original password for it in the first field, but leave the new password fields empty. It will complain that the new password is not secure enough but you can just override this by holding the Option key and clicking OK.
Now drag all of the items to the new login keychain and just click allow for each one – this is much better than having to type in your old-login keychain password every time you want to copy an item!!
Once done, simply delete the old-login keychain.
It’s ok to open Apple Mail now – all your email accounts and email should be present, the only thing you’ll have to do is re-arrange the left panel to how you like it (all mailboxes should be present though).
Copy the contents of /.Library/Application Support/Address Book, from the backup to the new install. Again, feel free to create a new folder called ‘orig’ and move the original files that are on the new install into it – so you don’t have to overwrite them.
Hidden files and folders
Move the /.ssh folder from your backup to the root of your new home folder.
Repeat for any other hidden files you need, such as the .bash_profile and .gemrc etc. (I recommend copying program specific files after you have installed them, such as .gvimrc, .gitconfig, .vim/colors directory, etc.)
Safari passwords, bookmarks and topsites
Keychain should have taken care of all your passwords, but to copy your bookmarks and topsites as well, simply copy these from the old home folder to your new one (to the same location)
While in the /.Library folder – you might want to copy over your iMessages archive and double click any fonts you want installing.
Restoring the rest of the home directory
You can now move all your other files from the backup to the new install, though I would move the contents of folders rather than the folders themselves if the folder was already created by the new install – such as the Pictures, Music, Movies, Documents folders etc.
The other folders can just be copied over.
Well that’s it! If you are a Ruby dev, check out my next post which shows you how to set-up a Ruby dev environment on Yosemite 🙂