Tuesday, September 24, 2013

6. Backups

No matter how big or small your project, you need to backup your data! Why not do it for FREE!
Most people do not know how backup your data properly. If you are building an HTML site or any size application, you need to backup your data. I will explain how to do that correctly and for FREE. 

Online repositories

High end applications can have more than one person working on it. There can be one person per project file or multiple people working on the same project file. The system that stores all of the files in a large application is called a data repository. If the data is on the internet, it is referred to as an online repository. If the data is on your computer, it is called a local repository.

If you backup your data, you can retrieve the backup after you accidentally delete, modify or corrupt any file. But, not only are you limited to whatever you backed up, you also can only retrieve the one backup you made. If you have multiple backups you can get older files but it is usually not easy. Of course if your computer is stolen or gets a virus, without a backup, you are screwed!

If you use an online repository, you have all of your data safe online. You get a free online "folder" that manages every version of every file you use for each project. Anyone can download the entire repository and get every version of every file you have made in your project. It also has tight security and can be configured to transfer all of your files securely.

There are many free online repositories. SourceForge, GitHub and Bitbucket are the most popular. All three allow unlimited space and free hosting for source code. I use Bitbucket because you can setup 5 repositories with 5 users each, all for FREE! It also includes an issue tracker.



Version Control Application

In addition to an online repository, you also need version control software installed on your computer. I will explain how to use TortoiseHg, a version control software for PC's. If you are running a MAC, you can use SourceTree.

People usually think of a backup system as being capable of doing the following tasks.
  • Backup my data.
  • Retrieve a file from my data.
That sounds easy. But, in order to take advantage of the power of a Version Control Application and be ready to scale up any project, you will need to learn how to do the following tasks which I explain below.
  1. Create a local Repository.
  2. Manage local Repositories. 
  3. Commit a change to local Repository.
  4. Upload to online repository.
  5. Download from online repository.
They are very similar to the two steps above (backup and retrieve). But, there are a few other steps because you have the entire backup on your machine and on the online repository (e.g. Bitbucket). 

In order to backup, you first commit a change to your local repository. Then, you upload it to the server (bitbucket). 

To retrieve a file you simply view the history of files and then retrieve any version you previously committed. If your computer gets corrupted, you have the entire repository safe, on the server.
One of the advantages of using a Version control software, is your do not have to save any document as version 1, version 2, etc. Just name every file exactly what it should be called, then backup every version (or "commit" every change, as I will explain below).
1. Create an local Repository

Have you ever bought a new DVD disk or flash drive to backup some data? First it costs money, and second it is not as easy as creating a new repository on your computer to store backups. With the use of a version control system, you will never have to buy another backup disk again, and it's always FREE!

When you start building a new application, one of the first things to do is create a repository to store your files for each project file that you will be building for the application.

Here is how to create a new repository on your computer using Bitbucket (installed).

Open up Windows File Explorer and navigate to the folder where you store your project files. If you have multiple projects for you application you will need to repeat this for each one. 

Right-Click with your mouse in the center of the File Explorer, inside the folder. You will see the following menu. Choose Create Repository Here. When the dialog comes up, leave everything alone and click on Create and you are done.

































This does not backup any data, it simply creates a new local repository for you to store you data. 

When you create a local repository, it creates a folder called .hg. Do not delete, edit, move or modify this file. This is your physical repository, which is actually a compressed package of all of your files. 

2. Manage local Repositories.


Now that you have a repositry, you want to open it up in the TortoiseHg interface to view your backups. From within the TortoiseHg workbench interface, choose File \ Open Repository. Choose the folder you created and open it. Once open, double click the repository listed on the right, you can see the files as displayed in the image below.
























3. Commit to local Repository.

Every time you want to save a backup, usually every night or when you complete something, follow these steps to commit changes to your local repository:

The top item will be called Working Directory, click on it to see what you have recently edited (files are listed below). Of course, you have to have changes to commit or this will not work!

Click on the button above the files to make sure you have selected all files to be added or removed.
















Type in something to describe your modification into to the box then click Commit. Keep in mind, the files must not be open when you click on commit or it will not work. 











Before you can upload to an online repository you need to setup an account with an online repository. If you have not done already, go to bitbucket.org and create a new account and repository. Once you do you can choose the repository. Name the repository the same name as your Flash Builder or Flash Develop project file name. Make sure you have chosen local repository you want to synchronize and working directory has been selected. 

After you commit your files, the file icons in your project, viewed from Windows Explorer will have a green check mark next to them. When you modify files, the green check changes to a red one.

4. Upload to online Repository

After you commit changes to your local repository, you can upload it to the online repository anytime you want. If you are working alone, you might update your online repository around every week or so. But, if you are working with other team members, you will need to update the online repository daily so that other team members can get your changes.

  • Log into Bitbucket and select your repository. 
  • Choose HTTPS from status dialog pull down, as shown in image below. 




















  • Copy the address displayed into your clipboard. 
  • Enter TortoiseHg and select your project.
  • Select Working Directory.
  • Click on Push Changes button as shown on the image below.










An error will appear, click OK.
  • Paste the address into the box provided, as shown in the image below.










  • Click on Push Changes again.
  • Supply your Bitbucket password to start the upload. 
In a future blog, I will explain advanced version control techniques like branches, pull requests, forking and merging code. I will also explain setting up secure connection with your online repository through "configured files" so that the process does not include copying and pasting anything.

5. Download from online repository.

Now that you have an online repository with all of your data, you can have other team members download it. Or, simply access it to replace corrupt files on your computer. 

When they download the repository, they are downloading every version of every file that everyone has ever made for that project.

Bitbucket makes this real easy; you can view the entire folder structure with the Source button. To download the source code, click on Download, on the bottom of the Bitbucket status area, as seen in the image below.



















 

About Sonoma Data Solutions LLC

My company, Sonoma Data Solutions is located in Sonoma County, in northern California. I started my company with the goal of building high end applications. I have worked for HP, Agilent, and on applications for EA Sports and Disney.

We provide full services to conceptualize, design, build, test and deploy your application online. We also provide financial options to make your application a reality.
Do not wait to build your application, define and grow your brand, and monetize your ideas.
Check out my website or contact me if you have any questions.

Thank you, 
John Molinari

Sonoma Data Solutions LLC
john@sonomadatasolutions.com


PREVIOUS POST  - NEXT POST


No comments:

Post a Comment