Sunday, May 3, 2015

Backup solution - Very Simple Example for Techies - When was the last time you backed up your personal computer?

Have you backed up important files on your personal computer?

We are all guilty of procrastinating this task and we don't see a value in this until we feel the pain of losing years of family photos one day.

Let's pick today as the day when we are going to start performing the regular backup.

There are many different solutions for backup. Some are relatively cheap and some are expensive. If you have nothing to hide and you trust the cloud enough, I strongly recommend that you back up your day to day files Google Drive or Dropbox or Microsoft OneDrive or even Amazon Cloud. Besides having a good cloud backup, it is also convenient because those files follow you from computer to computer.

This article is NOT about cloud backups. It is about you purchasing a USB device and backing up your files once a month onto your USB drive. So what is the worst case? You would lose the most one month of data if your computer crashes.

The goal is to make it as easy as possible so you don't have to copy and paste a bunch of folders and files manually. The goal is to have it scripted/automated and guess what... these scripts are free. This solution just requires a bit of computer skills that intermediate-level users of Windows operating system should be able to handle.

Let's get started ! This template script is the one that I use for my personal computer backup.

I am providing you below two Windows batch scripts that work as one application and perform the backup of your important files by just double-clicking on it. However, you will need to do some initial setup and then subsequent steps are very easy.

Setup Instructions:

If you are not comfortable doing the following steps, find a techie friend who can set this up for you in a few minutes.

  1. On C:\ drive create a folder called BackupScripts
  2. Go inside that folder and create two files invokeBackup.bat and backupScript.bat by taking the content of these from below.
  3. Create a shortcut on your desktop to invokeBackup.bat file.
  4. Open backupScript.bat file by right-clicking and pressing Edit. Then in that configuration section, edit the names of the folders that you want to back up and also the names of destination folders. You can use the examples that I provided in the sample script.
  5. Once you set up this backupScript.bat file, there is no need to open this any more in the future unless you decide to add brand new folders to the list of folders that you wish to back up.

How to Run the Script when you want to perform the backup:

I happen to put a reminder for myself to do a backup once a month. Here are the steps that you need to execute:

  1. Take your USB drive and plug it into your USB port. Make sure that its capacity is big enough to hold all the data that you are planning to back up.
  2. Look at the drive letter that was assigned to this USB drive and then open invokeBackup.bat file (by right-clicking the file and selecting Edit). In the script edit the variable USB_DRIVE_LETTER to the correct drive letter for your USB drive.
  3. Also in that script, edit the date. This date is useful as the script generates a log file of what it backed up and saves that into a file that starts with "BackupLog".
  4. Save the invokeBackup.bat file and exit out of it.
  5. Then run invokeBackup.bat script by double-clicking on it within C:\BackupScript folder or by double-clicking on the shortcut that you created earlier in the setup. When you double-click on it, it will pop-open a command-line window.
  6. If this is the first time doing it, then you go browse to your USB drive and look inside the backup folder and see if the files are being copied there. If they are, then everything is working fine.
  7. The backup is done when you see a message in that command-line window that the backup is done.

For example, I have 400-500Gb of data that I need to back up. This takes hours and the beauty of this script is that I can walk away from my computer and check the progress many hours later. I typically run this over night and check the status in the morning. If your backups are long, you need to make sure that the power options on your computer are set up so that your computer does NOT go into sleep if there is no activity (mouse movement) on the computer. I typically set the power option so that my laptop does not fall asleep while it is connected to power.

I strongly recommend that you perform the backup of your personal computer to two different USB drives and take one of your drives to a family member that you trust. 

Enjoy !!


@echo off

REM ****************************************************************
REM ****************************************************************
set backupDate=2015_05_03
REM ****************************************************************
REM ****************************************************************

REM ****************************************************************
REM STARTING THE BACKUP ********************************************
REM ****************************************************************
set LOG_FILE=BackupLog_%backupDate%.txt
echo STARTING...
date /t
time /t

echo starting > %LOG_FILE%

REM Invoke the main script to start backing up
call backupScript.bat %USB_DRIVE_LETTER% >> %LOG_FILE%

REM Copy the log file and some finishing touches
xcopy /E /V /R /Y %LOG_FILE% C:\BackupScripts
echo DONE
date /t
time /t

REM End of script



@echo off



echo *********************************
echo Start backup
echo *********************************
date /t
time /t

REM *******************************************************************************************
REM THIS IS WHERE YOU CONFIGURE THE PATHS and DESTINATIONS of folders that you want to back up
REM *******************************************************************************************
set DIR01="C:\MyStuff\MyNotes"
mkdir %DIR01_DEST_A%
xcopy /E /V /R /Y %DIR01% %DIR01_DEST_A%

set DIR02="C:\MyStuff\MyPics"
mkdir %DIR02_DEST_A%
xcopy /E /V /R /Y %DIR02% %DIR02_DEST_A%

set DIR03="C:\MyStuff\MyVideos"
mkdir %DIR03_DEST_A%
xcopy /E /V /R /Y %DIR03% %DIR03_DEST_A%
REM ********************************************************************
REM ********************************************************************
REM ********************************************************************

date /t
time /t

echo *********************************
echo End backup
echo *********************************


- -

#backup #cloudbackup #GoogleDrive #Dropbox #OneDrive #USB #USBdrive #batchscript #scripting #batchfile 

No comments:

Post a Comment