Using Dropbox For An Easy Restore Of All Your Computer’s Settings

Just to be clear, Dropbox isn’t backup software; it’s a syncing service.  If you delete a file and that change is synced, and your file no longer exists.

I really love the things you can do with Dropbox.  And since I’m stingy, I wanted to use Dropbox for backing up–and more importantly–restoring my computer.

One thing I always hated about getting a new computer was losing all of the customizations and settings that accrued over time.

Before this little trick,

I would spend an entire day re-configuring my computer to get it back to the way it was.

But thanks to some age-old technology, I can get a new computer any time, install Dropbox, run my script, and my computer will instantly be just like the old one!

Why Not Just Use Time Machine?

This method give you the added bonus of having all of your main computer’s documents available to you in Dropbox, so if you are mobile or on the go, and want to access a document you had on your Mac, you can just access it anywhere from Dropbox.

 

Some Background

This will work only on a Mac or Linux box for now unless you want to install some additional software onto Windows and even then there’s no guarantee.

For this article, I’ll be using the word backup, even though it’s technically incorrect.

People often talk about making sure your computer is backed up.  What you hear less often is about the restoration of those files.

Your backups are useless if you can’t easily restore them.

This concept is what made me think about Dropbox as a backup restore option because of how seamlessly it syncs changes to my computer.

All Of Those Settings I Changed Over Time

One thing I never liked about getting a new computer was having to rebuild all of my preferences, reinstall my apps, and reinstall my plugins.  I wanted to be able to quickly restore things like:

The above are all things that I added to my comptuer over my time, but became very hard to live without.  So when I got a new Mac and just restored my files, all of these apps, plugins, and settings had to be rebuilt.

The Plan

I have already shown you how to use hard links and soft links to sync your OpenEMU saves to Dropbox as well as how to keep your Dropbox folder clutter-free.  Using these same tricks, I’ll show you how I backup my Mac for a seamless restore.

Symlink My Home Folders

I created a hard or soft link for all the files/folders I wanted to be able to restore.  This required a little bit of knowledge on where macOS stores a lot of it’s files.  In the end, my Dropbox folder looks like this

dropbox-folder-links

You’ll notice all the folders in my Dropbox are named the same as the ones in my home folder.

home-folder

And you’ll also notice that the folders in my home folder are recognized as an alias (soft link).

soft-link

So now, all the folders in my home folder are actually just a shortcut pointing to a folder of the same name in my Dropbox folder.

To do this, I:

  1. created a new, empty directory in my Dropbox for each of the folders in my home directory (~/Desktop, ~/Documents, etc)
  2. copied all of the files from the existing folders in my new Dropbox directory
  3. deleted the real folders (~/Desktop, ~/Documents, etc.)
  4. created a soft link in my home folder (via the command line) that pointed to the duplicated folder inside my Dropbox (which now contained everything that was originally in my home folder)

So now, all of the folders in my home folder are now being synced up to Dropbox and the folders in my home directory are just aliases.   Anytime I save a file to my Desktop (or any other folder), it’s automatically synced up to Dropbox.

One folder I left off was the Downloads folder because it can get so unruly and often only holds temporary files that get put elsewhere, so I didn’t need all that additional network traffic.

Hard And Soft Link My Library

So what about the Library folder, which contains preferences and Application Support files?  This was a little more difficult because the Library folder also contains a bunch of useless temporary files such as Cache and Saved Application States, which I didn’t want, so I couldn’t just create a single sym link to the root Library folder or all that junk would get synced up to my Dropbox.

library-folder

Instead, I cherry picked the folders and files I wanted and re-created that structure.  For this, I used a combination of hard and soft links depending on what I wanted to keep.

The Beauty Of A Restore

I was able to test out the restore functionality and using a little script I made, it worked great.   The script deletes all of the existing folders and then creates the hard/soft links for me so as soon as my data was downloaded from Dropbox, my computer was exactly as it was.

I won’t post my entire script here since I don’t recommend you try this without some scripting knowledge, so if you know what you are doing, this should be enough to get you going.


filesToReplace=('~/.bash_profile'
'~/.inputrc'
'~/.ssh')

for filename in "${filesToReplace[@]}";do
  # Remove the file or directory
  # Since I assume I am running this on a brand new computer, 
  # nothing exists in the folders anyway, so they can just be removed
  rm -rf "$fileOrDir"
  # Replace it with a hard link to the Dropbox file
  ln ~/Dropbox/"$(basename filename)" $filename
done

# For every directory in your Dropbox/Library/Application Support folder 
# (these should be the directories you want to be backed up)
for dir in ~/Dropbox/Library/Application\ Support
do
 # remove the ~/Library/somefolder
 sudo rm -r ~/Library/Application\ Support/"(basename $dir)"
 # and replace it with a symlink to the one in Dropbox
 sudo ln -s "$dir" ~/Library/Application\ Support/"(basename $dir)"
 fi
done

Caveats

The great thing about this is that macOS just thinks the folders are as they were so it functions the same.  However, I did get an email from Dropbox warning that if I use iCloud and have sym links in my Dropbox, it could permanently erase the files from both locations.

dropbox-icloud-warning

That’s a huge bug!  Fortunately, I have iCloud Drive disabled and I never use it, so this has never been a problem.

Syncing The Applications Folder Is Difficult

Many applications need root access and the permissions on many of the files within the app bundles make it difficult to sync up to Dropbox.

Lessons Learned

Overall, I’ve been happy with this solution.  It’s also nice to have all my desktop files available on my phone without having to remote into it.  I also really like the fact that I can just keep everything in the place that Apple recommends, so I don’t need to change my behavior that much.

 

7 Replies to “Using Dropbox For An Easy Restore Of All Your Computer’s Settings”

  1. I don’t see the shortcoming of using macOS’s built-in Time Machine if you’re straight-up replacing one Mac with a newer Mac. That is, unless you don’t own an external drive for regular backups.

    1. I love Time Machine myself. One thing I probably did not make clear enough in the post, is the ability to have all of your Mac’s documents available on Dropbox. This means, that document I was just working on or photo I was editing is available on Dropbox. I can log in on any computer and get my Mac’s documents. It’s a nice alternative if you want to stray from Apple’s walled iCloud garden.

Leave a Reply