In software development, as in the real world, stuff happens, and it is important to be prepared. There is a lot that can go wrong when developing a website or an app. It is therefore important to be prepared for any eventuality.
The other day, I was working on a new website project. The website was by all measures complete, except for a few minor touches. I do not know what I did, but all of a sudden, when I refreshed the page, the header and footer of the site were missing.
In a panic, I tried to figure out what could have caused the destructive change. But like I said, I had no clue. Nothing was obviously out of place. It is one thing when you know how you messed up, but quite another when you are clueless. How do you fix something when you do not know what went wrong?
Stuff like this sometimes happens in software development. That is why it is important to always have a solid disaster recovery plan. When faced with a problem like this, you have a few options to consider before moving forward to recover.
Disaster in software development is often spelled by loss of data, or an application that inexplicably does not work. Sometimes when an application does not work, it is possible to reason your way out of the predicament.
Reasoning your way out of a problem takes time, and retracing of steps to see where it all went wrong, is no easy task. This is often complicated when a team is involved, because it means that more than one person could have messed up. This is further compounded of course, by the need to establish when this happened and where.
For data loss, the solution is often a backup of some sort, that will allow you to revert to a certain level of accomplished effort. Backups allow you to go back to a certain consistent working state. There might be some work effort lost when reverting to a backup, but at least you do not have to start all over again.
The worst alternative, is to lose everything. This can happen when you do not have a backup and you lost data, or your application is not working in its current state, and you can’t figure out where to start, in order to recover.
There is nothing as painful as losing project work, and having to start all over again. It is so painful because, you would have lost hours upon hours of work, together with the creative effort that went into building a project. This pain is something that can be avoided by having a project disaster recovery plan.
It is ideal to develop good habits. Good habits as a developer make you act proactively, so that you always work with a contingency in mind. It means always having in the forefront of your mind, the idea that data loss and errors are bound to happen.
One of the habits to develop is to save often. This is simple but highly practical habit, especially true if you are working from a desktop that does not have an Uninterruptible Power Supply (UPS). On such devices, when the power cuts, you lose everything you were working on from the last time you saved your work.
I work on a laptop, so I do not worry about the power suddenly cutting out, but even in my case, it is critical to also save often because, you never know when something can go wrong with the computer. For example, the computer might freeze and force you to restart.
Saving files to another location, other than the one you are working on is a good idea. The other location can be a local external device or the cloud. This is ideal for files other than code. There is a better way to backup code in the form of version control, which will be discussed shortly.
In a software development project, there are other files associated with the project other than code. Such files may include things like assets, that are not code such as images, or even files such as documents received from clients, and other files associated with the project.
External devices are a good way to backup such files, since the external device is in a way separate from a developer’s computer, and when something goes wrong with the computer, the external device can be the life-saving recovery plan.
It can become tedious to continually save files to an external device. Fortunately, there are tools that automate this process such as RSync on Linux or Mac, and Windows has similar tools as well. These tools allow you to easily backup only the files that have changed.
The cloud is a convenient way to backup files, especially because you can access the backed up files, from anywhere as long as you have an Internet connection. The cloud however is only great if you have a very fast Internet connection.
Version control is a system that records changes to a file or set of files over time, so that you can revert to specific versions later. I use a version control software called Git. This is perhaps the most important tool I use.
With Git, I am able to save the state of my working project at any point in time. The software will keep track of all these versions of files at all designated points in time. What’s even spectacular is that, I am able to revert to any of these “saved” states at any time.
The software allows for me to work in different branches as well. This means that I can get a copy of the state of my current files, and move them to a different work-space, or even have multiple work-spaces, and later choose to merge the changes into the original work-space.
Furthermore, Git allows for files and changes made to be synced to a remote server. Just like discussed above, this ensures that a separate copy of the software is kept safe, in case something happens to the developer’s local copy.
In a similar fashion, the software allows for team collaboration. Members of a team can work separately and independently of each other, and later merge their work into the master project. And if something goes wrong, the team can revert to any of the earlier project states.
Remember the little disaster I mentioned at the beginning of this blog post? When I was faced with a situation from which I could not otherwise recover, I simply reverted to an earlier working version of the website using Git. I was prepared and that’s the elegance of having a project disaster recovery plan in place at all times.
Want to hear some more from the Webmobyle Blog? Please