Can you use Robocopy to do incremental backup?
What is Robocopy? Robocopy (Robust File Copy) is a command-line for file replication since Windows Vista and Windows Server 2008. It functionally replaces Xcopy with more options, like mirroring, monitoring, retry when error occurs, etc.
When you use Robocopy to backup files, it actually creates an intact copy at the first time, and sync only changed files to target directory from the second time. So in a broad sense, you can use Robocopy to do incremental backup and therefore save your time & space. With some parameters or the help of Windows Task Scheduler, you could even perform Robocopy incremental copy automatically with a schedule.
There are some drawbacks about Robocopy, of course. It cannot copy open files or live operating system volume; The operation isn’t intuitive enough for users who are used to GUI software; And most of all, Robocopy won’t keep different versions of the source data nor provide image recovery.
That is to say, if you accidentally delete or modify something and run the backup unknowingly, these mistakes will be synchronized to the target directory, and you cannot retrieve any of the older copies.
If you don’t mind about it, keep reading and follow the steps to do incremental backup with Robocopy. Otherwise you could also use a backup tool with recovery options to avoid this situation.
Steps to perform Robocopy incremental backup on regular basis
First of all, the basic command of robocopy is: robocopy [source] [destination]
Open CMD and input this command, your files in source folder will be copied to the destination folder. Of course, you could enrich your Robocopy incremental backup script with practical switches.
To explain it further, I’ll give an example to backup files from C:\test to D:\test.
How to do incremental backup with Robocopy on regular basis:
1. Press Win+R key to open “Run” window. Enter “CMD” and hit OK.
2. Input the command and press Enter key to run the first-time backup.
robocopy C:\test D:\test
Check the target directory, you’ll find the files have been backed up successfully. If you add or modify files in source directory later and run Robocopy again, the changed and newly added files will be synchronized to the destination.
*Note if you want to copy all the changes & deletions in source directory as well, add /mir after the command. It also backs up all the subdirectories even empty folders.
*You could also use /xo to excludes older files. During copying the source directory, it will skip the files that already have the same or newer copies in destination directory. For example, if you first modify a file in folder A, and then the same file in folder B, the default incremental backup will copy A to overwrite B, while the /xo mode will skip the change because the file in folder B is newer.
*There are many other parameters, like /s (include subdirectories), /z (copy files in restartable mode), /np (don't display percentage of copied files) and so on. You could combine Robocopy incremental backup with switches you need.
For example, the command could be like:
robocopy C:\test D:\test /s /xo /z /np
3. To perform incremental backup with Robocopy on regular basis, you can either add parameters or use Windows Task Scheduler.
☛ By parameters:
/MON:n will monitor the source directory and execute incremental backup when "n" or more changes are detected.
/MOT:m will execute another incremental backup if changes are detected in "m" minutes'.
/RH:hhmm-hhmm makes Robocopy to copy files between "hhmm" and "hhmm", e.g. “/RH:1700-1800”.
In my case, I use the command below to back up changed files every 10 minutes.
robocopy C:\test D:\test /mot:10
*If you want to terminate the task, you could open another CMD window and enter “taskkill /f /im robocopy.exe”.
☛ By Windows Task Scheduler:
Open notepad, enter the command you want to implement. Here I want to copy all the subdirectories, so add the parameter /s as well.
Click File > Save As. Then give it a name you like, Robocopy incremental backup, for example. Change the extension from .txt to .bat. and click Save.
Search for Task Scheduler in Windows or in Control Pane. Open it, choose to Create Basic Task.
Enter the task name and description, then choose when or what to trigger the task. Here I choose Daily and specify the time point in the next page.
Choose Start a program as the action to perform the task.
Then click Browse to select the Robocopy incremental backup .bat file you just created.
Confirm the information and click Finish to complete the process. Then you can find the scheduled task in Task Scheduler Library and execute or delete it anytime you like.
Note there are many parameters to customize the backup. If you have further needs, there are some common switches you could use in your Robocopy incremental backup script. Click here to view the full edition of Robocopy syntax.
/s Copies subdirectories and excludes empty directories.
/e Copies subdirectories and includes empty directories.
/z Copies files in restartable mode.
/b Copies files in Backup mode.
/purge Deletes destination files and directories that no longer exist in the source.
/mir Mirrors a directory tree (equivalent to /e plus /purge).
/mov Moves files, and deletes them from the source after they are copied.
/move Moves files and directories, and deletes them from the source after they are copied.
/mon: Monitors the source, and runs again when more than n changes are detected.
/mot: Monitors the source, and runs again in m minutes, if changes are detected.
/rh:hhmm-hhmm Specifies run times when new copies may be started.
File selection options
/a Copies only files for which the Archive attribute is set.
/m Copies only files for which the Archive attribute is set, and resets the Archive attribute.
/xc Excludes changed files.
/xn Excludes newer files.
/xo Excludes older files.
/is Includes the same files.
/it Includes modified files.
/maxage: Specifies the maximum file age (to exclude files older than n days or date).
/minage: Specifies the minimum file age (exclude files newer than n days or date).
/r: Specifies the number of retries on failed copies. The default value of n is 1,000,000 (one million retries).
/w: Specifies the wait time between retries, in seconds. The default value of n is 30 (wait time 30 seconds).
/l Specifies that files are to be listed only (and not copied, deleted, or time stamped).
/x Reports all extra files, not just those that are selected.
How to do scheduled incremental backup with recovery option?
Like I said at the beginning, it’s risky to back up your important data with Robocopy, because there’s no rollback option for the mistaken changes and deletions that have been copied to target directory. If you want to manage incremental backup more safely and intuitively, backup software like AOMEI Backupper Standard could serve you better.
Compatibility - It’s a backup & sync tool supporting all Windows OS and enables you to do full/incremental/differential backup between various devices (internal/external hard drive, USB, network share, NAS, cloud).
Image Backup - You could set up a scheduled task to run incremental backup automatically. Thus only changed files will be captured and you can easily roll back to any earlier version.
File Sync - In addition to recoverable image backup, you can also copy files with original formats using Sync feature, which is more similar to Robocopy incremental copy but with GUI. Schedule options are available.
*The free Standard edition could already meet most of incremental backup needs. If you upgrade to higher editions like Professional, there are more advanced features to enjoy: real-time sync, two-way sync, scheduled differential backup, etc.
Now, I’ll introduce the operation to perform incremental backup with the Robocopy alternative. You could download and install the software to get started.
How to do scheduled incremental backup with free software:
1. Navigate to Backup > File Backup. You could also choose Partition Backup, Disk Backup, System Backup accordingly.
2. Click Add Folder or Add File to select the source data.
If want to add files from network locations, click Share/NAS in the popping out window and then Add Share or NAS Devices to specify the path.
3. Choose backup destination. In addition to local folders or connected removable devices, you could click the small triangle to select network location or cloud drive as you like.
4. Click Schedule to create automatic backup. It’s run in incremental mode by default. Optionally, you could manage more backup Options or set up a Scheme.
5. Then click Start Backup to execute the task.
>> Incremental and differential backup will back up only changed files and therefore save your time and space. But incremental backup is based on the last backup, full or incremental, and incremental backup is based on the last full backup.
When it comes to restoration, incremental requires the last full backup plus all the subsequent incremental backups in order, while incremental needs only the last full backup and the latest differential backup. As a result, incremental backup is faster in backup, and differential backup is faster in recovery.
>> Image and sync are both considered as backup in a broad sense. But the former will create a recoverable image file, and the latter will create an exact copy for direct access and use. If you want to save different versions of the source data, image backup in incremental mode is obviously the better choice.
Robocopy performs incremental backup by default to copy only changed or newly added files. You can schedule it by additional parameters or Windows Task Scheduler. However, Robocopy doesn’t have recovery options to retrieve any of the older versions. If you don’t want to mess up the data nor lose some files irreversibly, it may be more reasonable to do incremental backup with specialist software.
As an alternative, AOMEI Backupper could help you set up incremental or even differential backup with schedule. All your copies at different time points will be saved for future recovery. And if you want to do it in Windows Server, don’t worry, there’s also specialized Server edition.