Best and easy way to backup your computer files using robocopy
With the growing dependence on computer systems we need to have backups of our most critical files unless maybe you want to have a miserable life when you loose a decade worth of data.
With the many free and premium backup software around that I have used, I still wasn’t satisfied due to several reasons(a story for another day…). But today I want to share how I do my computer backup and that for my clients.
How to Create an Automatic Backup using Robocopy
Robocopy (Robust File Copy for Windows) is a command line tool. And some might say it’s sooo 80s and outdated in this era of smart phones. But guys at Microsoft don’t think so, because even with the resent release of Windows 10, Robocopy is still included in it. I must admit that Robocopy really does a more than great job and I have come to love it. And then it’s free, we all love free things!
One of the primary reasons for using Robocopy, rather than many other free backup products out there, is that it does a mirror backup . This means that it will make an exact copy of the source directory in the destination directory. But be warned not to SWITCH on the mirror (/MIR) backup if you have files in the destination directory which are not in the source directory which you still want them, cause they will be deleted faster before you come to realize what has just happened. It has happened to me… So for our own ‘safety’ I will not include the Mirror switch (/MIR) in our Robocopy Backup Script below.
Setting up Robocopy to do Automatic Backup
The easiest way to use the ROBOCOPY command is to create a backup strategy is by creating a batch (.BAT) file. A batch file is a simple text file, that when executed, runs several commands one after the other.
- Setup a .BAT file with the Robocopy commands
- Schedule the .BAT file in windows scheduler
General Robocopy Syntax
The general format of the ROBOCOPY command is:
robocopy <source> <destination> <option> Robocopy options: Where: /E= copy all sub-folders, even empty ones /MIR= mirror (creates an exact copy of the source in the destination) /np= no progress counter /LOG: = create a log file /Z = ensure that any possible network outages do not cause some critical files to be skkiped (across a network) /XA:H = leave hidden files /MT = Specified 4 threads to use for multi-threaded copying /W:0 = wait time if file is locked (Default is 30 seconds) /REG = saves new default values of /W and /R to the registry > = New log file >> = Append on the previous log file pause = pause the command prompt window for viewing if need be
Step 1 – Create the Robocopy .BAT File
Open Notepad or Notepad ++ and type the following. Change the source path and destination path according to your needs. Save the file as a .BAT file.
robocopy C:\wamp\www E:\Backups\wamp /E /XA:H /W:0 /R:1 /REG /NP /MT:4 /Z /TEE >> E:\Backups\wamp\wampbackup.log pause
Step 2 – Schedule the Robocopy .BAT File in Windows Task Scheduler
The best way to do backups is to schedule the process. This ensures that the backup always runs. We are going to use Windows Task Scheduler to schedule the robocopy backup script.
- Click the Start button and search for Task Scheduler.
- Click to open the application. The below screen will appear
- Click on Create Task.
Enter the name and description of your task. Choose ‘Run whether user is logged on or not‘ option. Check ‘Run with highest privileges‘. Under the configure for, choose your appropriate Windows Operating System, mine is Windows 10.
Under the Triggers tab click on New. The following window will appear. Select how you want your backup to run. In our case we want the backup to run on daily basis. Choose what time the backup should run. Tick the enable button.
If you want your backup to run more than once in a day. Choose the ‘Repeat Task Every‘ option and set time intervals. You can also set the task to stop if it run for more than a specified amount of time. Click Ok button when done.
Click on the Actions tab. Click on the New button as shown below
On the new Window which will appear choose ‘Start a Program‘ under the action. Then click the Browse button and locate the robocopy .BAT file you have just created. Click Open as shown below.
When done, your Actions tab settings show look similar to the below screen short.
Here we can condition when the script to run.
Untick the ‘Start the task only if the computer is idle for’ check box. Unless you want your backup to only run when the your computer is in idle state.
We can also choose whether the backup should only run when we are on AC . I normally uncheck this check box.
If you are backing up in a network location you might need to check if your computer is connected to the network. To do this go under the Network settings, tick the ‘Start only if the following network connection is available‘ check box and either choose Any Connection or choose a specific connection.
Click Ok when done. An authentication screen will appear enter your windows login password and click ok and you are done.
Hope you enjoyed this article. To get more details on robocopy you can see this article from seven forums.