Aug 9

If you’ve been following my series of posts on scheduling automatic backups to the cloud, you’ll have read how it’s possible to select just the daily, changed files for backup. It occurred to me when setting this up that what I also needed to be able to do is delete files older than a certain age from the backup folder.

Why delete files?

Well for me, my main backup location is my external hard drive. As a secondary backup, I backup all important daily business files to my cloud storage until a client job is satisfactorily completed, then I can delete them from this secondary storage. Another reason for deleting files is when a business client specifies that I delete them a certain number of days after job completion. Finally, most cloud storage providers only give you a limited amount of free storage, so it’s useful to be able to delete files older than a certain age to prevent going over the free quota.

Batch file to delete old files

A quick Google search revealed that Windows includes a program called forfiles which will do this job – I had no idea about this! Here’s the basic line you’ll need to add to your backup batch file:

forfiles.exe /p “C:\<directory with files>” /s /m *.* /d -<number of days> /c “cmd /c del @file”

Looks daunting, but it’s just the program name followed by a number of parameters. What follows /p is the path to the files to delete; /s tells the program to delete from subfolders as well; what follows /m specifies the file types to delete; what follows /d is the key parameter here and selects files with a last modified date earlier than or equal to (-) the current date minus the number of days specified, e.g. /d –45 would delete files older than 45 days; what follows /c runs the specified command on the path specified earlier. Command strings are enclosed in quotation marks.

I’ve added this to my scheduled batch file given in the earlier post so it now backs up encrypted daily files and also deletes all files older than 45 days. These changes are then synced to my cloud storage.

Finally, a word of warning. Deleting files is dangerous, especially when you are setting up scheduled automated deletion. Be sure to back up all you data before testing and implementing this routine.

Jul 25

I’ve already blogged about scheduling daily backups of changed files to cloud storage. Well, that’s fine but what if you want the added security of encrypting the files before you upload them? Well I’ve found a couple of ways to add client-side encryption to the backup process, just in case you are uneasy about sending unencrypted files to the cloud. I read a post about Cloudfogger on the tech blog Instant Fundas. Cloudfogger adds a virtual X: drive to your PC where your changed/new documents are passed to first. Cloudfogger then encrypts the files using AES 256 bit encryption and sends them to your nominated drop folder on your PC. From there, the encrypted files are synced to your cloud storage. In my case, the CX Sync folder mentioned in my earlier post is my drop folder syncing to CX in the cloud, but you could just as easily use Dropbox or Microsoft SkyDrive as your drop folder.

So instead of backing up changed/new files to the CX-Sync folder as in the earlier post, you now backup to the virtual X: drive instead. Here’s an example batch file:

echo off

echo Encrypted daily files to CX

Robocopy “c:\Users\<user name>\Documents” X:\  /MAXAGE:1 /S

echo Backup complete

The changed files are thus copied to the X: drive by this simple batch file, then encrypted and passed to your nominated drop folder:


The encrypted files in your drop folder are then synced to your cloud storage.

One drawback of this automatic approach is that everything is sent to the same drop folder and thus sent on to the same online storage provider. Suppose you wanted to send different encrypted files to different cloud storage providers? Well, you could use a second encryption app like SecretSync to pass other encrypted files to a second drop folder and then on to a different cloud storage provider. And you could set it all up as a second scheduled task, just as I’ve outlined in the earlier post.

So now all your daily data is secure in the cloud using a simple batch file and Cloudfogger together with a cloud storage provider like CX, Dropbox or Microsoft SkyDrive.

May 16

I’ve already talked about my backup routine in an earlier post. Part of that involves daily backups to CX (Cloud Exchange) –  it’s my first choice cloud storage site as it gives 10GB free storage. Like Dropbox and SkyDrive etc, just drag your files to the CX desktop folder and they are automatically synced to the cloud.

That’s great, but what about scheduling automatic daily backups of your changed documents to the cloud? For me, it’s important to have a second copy of my recently changed work files in the cloud, just in case my PC doesn’t boot next morning, for example. We need a way to automatically select documents you’ve worked on that day, and at a preset time, copy those files to your CX folder for syncing to the cloud. I’m going to show you how I do this.

Get some free cloud storage

If you haven’t already done so, sign up for free cloud storage and make a note where your desktop folder is for syncing to the cloud. For me, it’s C:\Users\<user name> \Desktop\CX Sync.

Create a batch file to copy daily changed files to the CX folder

Yes, I know batch files are a little old school but, once set up correctly, they get the job done. We’ll make one to execute a simple command to copy today’s changed files to our syncing folder, but first why select just changed files? Well, if you have a good backup routine in place, all your documents older than today should be on your external drive anyway. During the current day, you’ve been editing documents, photos or videos and these current files should be backed up to your external drive and the cloud at the end of the day. You could use a backup program but why download another utility when you already have the tools to do it for free in Windows.

We can create a batch file with a text editor like Notepad++. In the batch file, the command Robocopy is used to copy your daily files from the source folders to a destination folder, your syncing folder. Robocopy is available in Windows Vista and Windows 7.  The format for the Robocopy command here is Robocopy <source folder> <destination folder> switches. The switch /MAXAGE:1 makes the command select just today’s files (i.e. it excludes files older than 1 day). The switch /S tells Robocopy to copy subfolders. Open your text editor and copy and paste the following lines to make your batch file:

echo off

echo Daily files to CX

Robocopy “c:\Users\<user name>\Documents” “C:\Users\<user name>\Desktop\CX Sync” /MAXAGE:1 /S

echo Backup complete

You’ll have to edit <user name> to your own user name and you’ll have to change some details to point to your correct source and destination folders. The destination folder should be your syncing folder, in my case CX Sync. If the source or destination paths contain spaces in them, enclose these in double quotes as shown above. Now save it as a batch file (.bat) on your desktop, NOT as a text file (.txt). Give it a sensible name, something like Daily docs to CX.bat. Here’s how the Save as screen looks in Notepad++:

Save as batch file

Try it out by double clicking this batch file on your Desktop  to see if it’s copying today’s changed files to your syncing folder.

Schedule your daily backup with Windows Task Scheduler

So far so good I hope. But so far we’re relying on remembering to click this batch file each day. Much better if we could automate this process to run the batch file at a specific time each day, say 9pm when all work for the day is finished and we are doing other things on our PC. Well, we can set up Windows Task Scheduler to do this.

Click the Windows Start button and key in Task in the search window. This should bring up Task Scheduler on the list. Click it, then right click Task Scheduler Library and choose Create Task. Under the General tab, fill out the task Name:

Task Scheduler1

Then click on the Triggers tab and click New. Fill out the time for your scheduled backup to run and make sure Daily is selected. Click OK.

Task Scheduler2

Then click on the Actions tab and click New. Fill out the location of your batch file by browsing to your desktop and selecting the file. Click OK.

Task Scheduler3

Select the Conditions tab and set it up as shown.

Task Scheduler4

I found it best to uncheck the default ‘Start the task only if the computer is idle for:’ I want it to run right away at 9pm with no delay. Click OK to complete setting up your scheduled backup task and close the Task Scheduler.

When this scheduled task runs at your chosen time, it runs in the background anyway. The pause command at the end of the batch file means the window will remain open so you can check it has run correctly.  When you’re satisfied everything is okay, press any key to close the batch file window.

So there we have a free route to set up a scheduled backup of your daily edited files to the cloud without downloading any utilities. Eventually, when your free online storage starts to fill up, you can delete some of the older files to free up space. They should all be on your external drive anyway. How do you schedule backups? Have you any suggestions to improve this routine. I’d love to hear your thoughts.

Update (28 July 2012): If you want to take this a little further, and you’re interested in client-side encryption before backing up, I’ve recently added a new post on Scheduling Encrypted Daily Backups of Changed Files to Cloud Storage.

Sep 17
Preventing a hard drive disaster
icon1 techandlife | icon2 Backup, How to, Tech | icon4 September 17, 2008| icon33 Comments »

An IBM HDD head resting on a disk platter

Hard drive. Image via Wikipedia

If you’ve ever had a hard drive failure and lost irreplaceable photos and other data, you’ve already learned the hard way. Make no mistake, a hard drive definitely won’t last for ever so if you don’t backup your data, you need to start now to prevent a disaster.

Problem is, backing up your hard drive isn’t an easy process for the beginner or average user. Terms like cloning, imaging, incremental and differential backup are more familiar to geeks and advanced users than beginners, so many just wing it until disaster strikes.

Warning signs of hard drive failure

In some cases, you will start to see signs of a problem before the hard drive fails. Early warning signs include:

  1. Computer freezes often. When it happens, the mouse cursor is unmovable and keyboard input is ignored. Nothing works and a restart is required to recover the computer./li>
  2. Files mysteriously disappearing.
  3. Frequent lock-up during booting. I say “frequent” because all computers will freeze every now and then and it doesn’t necessarily mean the drive is failing. You’re looking for a pattern here.
  4. File access mysteriously slows to a turtle’s pace. Saving files or open files simply takes forever.

(from Hard Drive Failure: Warnings and Solutions; PC Mech)

In addition, you may get error messages during booting or the dreaded clicking sound or strange metallic noises indicating imminent drive failure.

I’m going to try and outline a reasonably straightforward backup strategy where you will always have a bootable backup hard drive with all your data should, or rather when, disaster strikes. We’ll divide it into four parts: (1) purchase a backup hard drive and external enclosure; (2) clone your hard drive; (3) backup your data and (4) recovery after a hard drive failure.

Purchase a backup hard drive and enclosure

I know this seems like overkill but it’s a great help if you get a backup USB external hard drive when you purchase your desktop PC or laptop.Iomega external hard drive We’ll see why shortly. Get a disk that matches the one already in your PC or laptop or one with larger capacity. If you’re not sure of the make and model, in Windows XP, you can find out what hard drive you have by double clicking on the My Computer icon on your desktop, highlight Local Disk C , then select File, choose Properties, then the Hardware tab. That should give the drive make and model. Or use a free system information program like SIW or PC Wizard to get the drive information. The enclosure will have a data cable and power connector to connect one end to the backup hard drive and the other end to a USB port on your PC or laptop.

Clone your hard drive

Assuming you have bought your external drive with your new PC, once you have installed Windows on your new system and your essential application software (applications) like word processor, email client, etc., remove any junk or unnecessary programs using PC Decrapifier. Once everything is set up just the way you want it and the PC is running fine, now is the time to clone or image the drive. You’ve probably heard the terms cloning and imaging and very often they are used interchangeably. I’m going to make a slight distinction which some people make.

  • Cloning is making an exact, uncompressed copy of your hard drive; just a mirror image.
  • Imaging is making a compressed copy of your drive as a file which can be restored or uncompressed back to your hard drive.

I thing cloning is more straightforward for the beginner/intermediate user, at least until you become familiar with the process.

At this point, I’m going to refer you to two excellent articles which will guide you through the cloning process:

Acronis True Image Acronis True Image is an excellent package and well worth investing in for both cloning and imaging.

So now we have a bootable backup hard drive in the external enclosure, with our Windows operating system, and our essential apps. We’re now going to regularly backup our data to this drive so that if disaster strikes we can be up and running again in less that half an hour.

Backup your data

There are different ways to do this from running a batch file which automatically copies your data across to the backup drive to using a backup or syncing program like the free Microsoft SyncToy, Allway Sync or SyncBack. These are probably the best options for the beginner. The important thing is to make sure you have backed up your Documents and Settings folder, including your browser bookmarks. Assuming you’re not using internet email like Gmail, find out where your email boxes are and be sure to back them up too and also any other important data not stored in the Documents and Settings folder. Use Explore to check down through all your folders and ensure that you are backing up all the data that’s important to you including your photos.

Make sure to backup regularly. Twice a week is sufficient for me. I use a batch file and just copy over files that have changed in my important data directories. Probably not a great solution for a beginner but here’s some info anyway.

Here’s a copy of a few lines from my batch file:

@echo off

echo pause

xcopy c:\”documents and settings”\user name”My Documents”\*.* F:\”documents and settings”\user name\”My Documents” /s /e /h /i /r /y /d

xcopy c:\”documents and settings”\user name\”Favorites”\*.* F:\”documents and settings”\user name\”Favorites” /s /e /h /i /r /y /d

echo backup complete

You can add extra lines for each main data directory you want to copy. Just change ‘user name’ to whatever your user name is, and you may have to change the drive letter for your external hard drive letter. You’ll be able to see that in Windows Explore. The xcopy command and the switches at the end of each line are explained here.

Another important point. Disconnect the backup drive when not in use to minimize the chance of any malware getting on it.

It’s even worth disconnecting your PC’s hard drive and plugging in the back up drive before disaster strikes to make sure it’s bootable and you’re backing up all your important data. Follow the procedure in the next section.


Recovery after a hard drive failure

If your hard drive fails, no need to rush out and buy a new drive and restore an image to it. No time lost there so this is a great solution if you don’t have a secondary backup PC and you rely on your PC for work. The beauty of this procedure is that all you have to do to get your PC running again is: unplug and open your PC, disconnect the data cable and power cable from the original dead hard drive and remove it, remove the backup hard drive from your external enclosure and connect up this bootable backup. Your operating system, essential applications, settings and data (up to your last backup) will all be there but you’ll probably have to install some programs which you put on between buying your PC and the disk failure. But this is a good chance to assess just what you were and were not using and be more selective in what apps you reinstall. The other big plus is that your registry is now virtually back to as it was when you first bought your PC and the machine will probably boot noticeably faster.

If you’re not happy about changing over the hard drives or if it’s a laptop and difficult to do, bring it to a reputable repair shop. It shouldn’t cost much to do. Get an estimate first from several shops if you like. Ask your friends if they have used a repair shop and can recommend one in your area. Or perhaps ask a geek friend to do it for you.

One last thing. Don’t forget to purchase a new (bigger) backup drive to go into your now empty external drive housing, and then repeat the cloning process before disaster strikes again. And keep backing up your data regularly.

Hope this has been of some help. Any suggestions to make it all easier? Anything I’ve missed? Drop a comment please and I’ll try and update it.

` `