[Sysadmin 101] Keeping Config Files Synced

One of the things I go REALLY tired of when I was setting up new machines without shared home directories was copying over ALL my personalized configurations over and over and over again. So I wrote a script to copy everything over. And then I realized that, somewhere along system number 10, the configuration files I was copying were tuned differently from the earlier ones, and in order to keep my settings consistent, I needed to go back and recopy everything…

…if you’re a developer or a sysadmin, you know where this is going. I checked everything into a version control system – git in this case – and started checking out the files on the new locations, and pulling updates on the others. This makes perfect sense, and as things get updated on one box, I can just pull the changes on the others on demand.

And this REALLY works well for me.

I recently added Dropbox to the mix. Howso? I moved the “master” git repository int a Dropbox folder. So on the machines where I have Dropbox (i.e. all my home systems, my work desktop, etc) I no longer have to pull the changes – Dropbox is doing that for me. And for the systems where I can’t use Dropbox (like the VM I have at Lylix or my hosted server out at Dash Systems) I can still check in & out the files like I always did.

I realize this is probably old news to some of you (and if you have a shared drive for your home directory, you probably don’t need this at all). Be aware that file conflicts might come up if you’re not careful, but in general it’s been the perfect solution for me.

So, for those who want to know “How I do that” and have a fair grip of the Linux and/or OSX command line, here is the step-by-step  :

  1. Get Dropbox if you don’t already have it.
  2. Create a folder in the dropbox called “myconfigs”
  3. Do a “git init myconfigs” from the Dropbox folder
  4. Identify what files you want to keep there.
  5. Move in the files into the myconfig directory, i.e. “mv ~/.bashrc ~/Dropbox/myconfigs/bashrc”
  6. Use a symlink to point back to the original location. i.e. “ln -s ~/Dropbox/myconfigs/bashrc ~/.bashrc”
  7. Add the files to the git repository with “git add”
  8. Commit the files with “git commit”
  9. Wait for dropbox to sync everything up
  10. On the next machine, make a backup of the old file, e.g. “mv ~/.bashrc ~/.bashrc.orig”
  11. Use a symlink to get the “common” file, just like above : “ln -s ~/Dropbox/myconfigs/bashrc ~/.bashrc”

Voila! You’re done. On systems that aren’t Dropbox-able, you can use the git clone/push/pull commands to get the same configs.

So what do I keep in my personal “myconfigs” directory? As shown above, my bash configuration. Also in there are my mutt configs, emacs configs, signatures, and some scripts I use for cron jobs – and other configurations that I need/want to keep consistent from box to box. I also added a shell script to do all the backup/symlink stems for me. Setup is now a breeze – get to new system, sync with Dropbox (or git pull), run script.

This has made my life MUCH easier, and bootstraps my productivity when I’m on a new system.

One final word of advice – some things you do NOT want to keep in there. I tried keeping my Thunderbird configs on Dropbox, and it was WAY too much churn. The same with Firefox and Pidgin. And until they get the security tidbits cleaned up, I’d avoid storing anything like ssh keys, password files, or gpg keyrings on there.

About Kevin Sonney

Kevin Sonney - who, contrary to popular opinion was NOT raised by wolves - grew up in central North Carolina. He fell into the technology field by accident in 1991, when he gave up the wild and crazy lifestyle of an on-air AM radio DJ to become a mundane technical support monkey. The technology industry has never really recovered from this. Kevin has worked for such names as IBM, Red Hat, webslingerZ, and Lulu Technologies (we won't mention the ones that didn't survive the experience). He currently works as a Linux Administrator for Apptio. In his spare time he rescues stray animals and plays video games with his two sons. His wife, we're sad to say, helps him get past the really hard bits. Kevin is still not very mundane, he just got better at hiding it.
This entry was posted in code, Personal, SysAdmin. Bookmark the permalink.