There are lots of commercial data back up solutions available in the market. If you are a home user or a small business user of Windows OS and want to backup all your important data then this article shows you a simple incremental backup solution with no additional cost. If you can’t afford to buy a commercial backup application don’t worry! You can still backup your data using Windows xcopy command.
Windows incremental backup
If you already understand what incremental backup is and it’s advantages, you can skip this and move on to next section that explains the syntax.
You can use a USB drive or an external hard disk as the backup location. Copying files to another partition on the same is okay but it may not serve the purpose as a disk crash will cause data loss on all the partitions of that disk. Let’s say your data is in the folder D:\Data and you need to backup your data to Z:\Backup folder (Z: is mapped to some external disk storage device). We can just copy data from D:\Data to Z:\Backup directly using any copy command or tool but it will involve copying the files even though they are not modified from the time they were copied previously. I will explain this in detail. Let’s say you take data back up every week. The first time you back up the data you need to copy all the files in your disk to the backup location. In the second week, you need to copy only the files that have been changed during the last 7 days. You do not need to copy the files that have not been touched since the time you took the last back up. This will save time and also decreases CPU usage and will also lead to increased lifetime for the storage devices. So a backup utility should be able to detect which files are modified and which are not. This is called incremental back up.
Using Xcopy command for incremental backup on Windows
Now let’s see how we can do this using Windows Xcopy command. Xcopy has different switches using which control what files to be copied. We will use these switches to make Xcopy work as a backup utility.
You can run the below command to back up data.
xcopy source destination /M /E /G /H /Y
This one uses archive attributes of files to distinguish the files that have not been changed since the time last back up was taken. /M switch turns off the archive attribute on the files after copying the file to the destination. This attribute will be set only if someone modifies the files after wards. For the above example the command is given below.
Xcopy D:\Data Z:\Backup /M /E /G /H /Y
Back up data using date and time stamps
We can do incremental backup by specifying the date the last back up was taken. Xcopy will copy only the files that have changed after this date. For this we need to run the below command.
xcopy source destination /E /G /H /Y /D:mm-dd-yy
Hope this post has helped you. Let me know your comments on this.
How to automate the backup operation? If I want to run backup using xcopy every Monday, how can I do it.
You can easily automate operations using Windows “Scheduled Tasks”.
Simply craft your commands in Notepad, save it as a batch file (name.bat), then create a scheduled task that executes the batch file. You’ll find the Scheduled Tasks Manager under Start>Accessories>System Tools.
It’s pretty intuitive- creating a new task is much like creating a new event in a calendar, except that ya can brows to where you saved the batch file.
need more?
jfgi ;^)
How to take backup file if the the folder name has dot in it.
For example c.files.com
Did you have any issue using xcopy on a folder with dots in the name? I just tried xcopy on such a folder and it worked.
I need to copy a folder & contents that has a dot(.) in the name to another sub-folder.
I can make it work if I include the explicit folder name (such as 1234test.NCD), but not with a wildcard (*.NCD) . In other words to put a copy in the MAKE\EXAMPLE subfolder:
a) xcopy /i /y /q 1234test.NCD MAKE\EXAMPLE\1234test.NCD works.
b) xcopy /i /y /q *.NCD MAKE\EXAMPLE\*.* does not work – no error messages.
Any ideas?
You might also mention / discuss xcopy’s problems with file / filepath size, and it (sometimes?) turns the destination directory into a hidden directory (requiring some attrib intervention to find again). Have a great weekend.
“You might also mention / discuss xcopy’s problems with file / filepath size, and it (sometimes?) turns the destination directory into a hidden directory (requiring some attrib intervention to find again). Have a great weekend.”
You can fix that by adding *.* to the source, that will fix the hidden directory.
example,
xcopy SourceFolderOrFile \*.* DestinationFolderOrFile
If you do have hidden directory, in windows 7. Tools >> Folder Options >> View Tab >> Uncheck “Hide Protected Operating System Files (Recommended)”
Very useful. I’m troubleshooting right now, and think I’m using the wrong switches. Eager to try yours.
My xcopy backup starts, copies the first six or so folders in the source directory, then stops at the same place every time. Not because the destination drive is full…it’s a TB drive, mostly empty.
Am off to change the switches.
Hi, I did the backup following this method, but now that I’ve restored my pc to its original settings, how do I restore my backup so I can re-install the software that I have in my backup file? Any help would be greatly appreciated.
Hay SRINI
i must say thanks a lot for your great and super cheap solution
It works!
Anyone know how to use xcopy so that it only backs up files that are going to be moved. For example say we have bunch of files in DEV environment that we’d like to copy and overwrite onto QA environment (and new files in different locations within main app folder) – but before we do we’d like to back up the same files that currently exist in QA onto a backup folder.
Please if l want to do an incremental backup after copying the whole files for the first time,does it mean l will need to modify the batch file with the /D:mm-dd-yy which was not in the script when l first ran the batch file to command everything
Hi,
Strange thing. I prepared batch file (for scheduling) and noticed that the script did not copy all files. Then I copied the command from script, run it and it worked fine. Anybody knows where is the problem? Thank you in advance for help :)
I recommend adding the /C switch (ignore errors) if you are going to run this in a batch file. I also am putting a @pause at the end of the bat file so that the cmd windows stays open and I can see it was run each morning.
Thanks so much, for finally explaining it crystal clear. So many videos and tutorials don’t come close to your concise info – and for that – I’m very grateful.
Thanks!
I have got a sharing violation error.