Backup and Versioning

This page discusses some techniques and habits for backing up and versioning your files that will save you a lot of frustration in terms of lost files and source code changes down the road.

Backing up your files

Always remember that your files are never completely safe. You may accidentally delete or overwrite the files yourself and it is also possible that they are corrupted through no fault of your own although very rarely (e.g. from OS malfunction, hardware malfunction, or even cosmic rays from space.. don't laugh, cosmic rays are actually a serious problem in IT industry). Whatever the reason, you are the one who is going to be left out in the cold if you do not prepare beforehand. And that also applies to projects for this course.

So how do you backup your files? The easiest thing to do is to make copies of important files using the UNIX 'cp' command we learned in the first lab. If one copy is compromised, you will still have another copy. You can also download files to your laptop for backup. Here are a couple of widely used free Windows file download programs you can use with the thoth machine: WinSCP and Putty PSFTP. The former is GUI-based and the latter is command line based for those of you who are familiar with the sftp protocol. Linux and Mac users have the 'sftp' client program pre-installed on their systems. There are also free GUI clients for Linux or Mac such as FileZilla.

When all else fails

Suppose you forgot to make backups and now you are pulling out your hair. Fortunately, the thoth machine is set up to make daily backups of your home directories, just for this type of situation. So if your original file was in:

$HOME/private/exifviewer.c

The backup file would be in:

$HOME/Backup/private/exifviewer.c

You may get confused because the Backup/ directory has the exact same structure as your home directory (because it's a backup). You can try doing the 'pwd' command anywhere to check where you are currently in the directory structure. It prints the current directory.

So assuming you find the above backup file and it's useful. You will do the following to recover the backup and overwrite the original file:

cp ~/Backup/private/exifviewer.c ~/private/exifviewer.c

WARNING: Do not work out of the Backup directory because files these will be overwritten daily by the system.

Versioning

Professional programmers do a form of backup called versioning. Rather than making manual backups of files, they take a snapshot (or version) of the current state of the project and store it in a safe repository using version control software. There are several widely used (and free) versioning software out there: RCS, CVS, SVN, and Git among them. RCS is your most basic version control software that is very easy to install and use. Git is much more advanced but is a little bit more complex to install and use. Using version control software, you can easily revert your project to any of your past snapshots using a single command, list the differences between your current project and past snapshots, and collaborate with other programmers in your project, among other things. All of the above version control software can be used with the thoth machine and you are encouraged to try using them (Git is the most popular with open source developers). But since versioning is an involved subject, we will not have time to discuss it as part of the course. Also, we will not be able to provide support and guidance in using them. So it's going to be entirely on your own initiative but once you learn it, it's going to be an extremely useful skill that you can even put on your resume.