Always Backup Your Data - Three Different Ways!
The last few weeks I’ve had disk corruption issues on my two year old Macbook Pro’s original internal hard drive. The machine and drive still worked, but I needed to bring the machine into the Genius Bar to get a hard disk replacement.
In preparation I dutifully backed up my machine via Time Machine to an attached Firewire drive at least every day. I dutifully backed up my source code to a remote server with git. I added a third layer of backup to my local NAS device using Chronosync.
Time Machine and git failed me. Chronosync saved me. If not for Chronosync I would have lost a full week’s worth of very intense coding, affecting dozens and dozens of files. I did still loose the revision history for these changes.
What went wrong?
I have no idea what went wrong. None of the modified source code files were shown as having changed during the previous week or more of Time Machine history, even though they had changed. I found a number of other recent file changes were also not backed up (as caught by my Chronosync restores). These included a few source files as well as a Pages word processing file. I suspect Time Machine’s process for detecting changed files isn’t sufficiently robust. Time Machine was, however, instrumental in a zero pain restoration of almost 100% of my machine and so I highly recommend that everyone on a Mac use Time Machine.
I was working in a branch. My branch changes were being stored in the local repository but were not being pushed to the remote server. This is because with git you need to specifically configure those branches that you want pushed. And of course since I lost my local repository, I lost all my changes. If you are using Smartgit you would see the push options shown in this screenshot.
I had been selecting the All Matching Branches option and had never selected and configured the Current Branch option for the branch in which I was working. This was newbie stupidity on my part, particularly because my push status showed Everything up-to-date, I should have clued in. At the same time, it is actually quite common for developers to create a local sandbox branch which does not get pushed to the remote repository, leaving a rather large hole in your backup strategy.
Chronosync got my source files, but missed my
.git subdirectory. I therefore lost my local repository and a week’s worth of history information. Why? Because I had set the ignore invisibles option to true, which should exclude all files and folders beginning with a
.. I had probably done this in the past to avoid backing up Eclipse
.metadata folders. I may also not have thought there was a need to backup the git local repository. I’ll now investigate a solution to just adding the
.git files without adding other invisible content.
I’m going to continue to use all three backup mechanisms, but with a new found awareness of Git and Chronosync options.