How to Automate Daily File Backups on Windows With Robocopy and Task Scheduler

You can automate daily file backups on Windows by writing a Robocopy command that copies your important folders to another drive, saving it in a small script and scheduling that script with Task Scheduler to run every day. Robocopy is built into Windows, handles large folders reliably, can resume interrupted copies and writes detailed logs. The key decisions are whether to mirror folders exactly or only add new and changed files, and how to check that backups actually succeed.

This guide explains how Robocopy works, the most useful options, how to avoid accidentally deleting files, how to schedule the backup and how to check results.

Automatic daily file backup Folders on a computer copying across arrows to an external drive with a calendar check and a log card
01

Why Robocopy for backups

Robocopy, short for robust file copy, is a command-line tool included with Windows. It copies only files that are new or changed, retries when files are temporarily unavailable, keeps timestamps and attributes and logs everything it does. These features make it well suited to regular backups of documents, photos, projects and AI outputs.

02

Understanding the basic command

A Robocopy command names a source folder, a destination folder and options. Microsoft’s Robocopy command reference lists the options, including /E to copy subfolders including empty ones, /MIR to mirror a directory tree, /Z for restartable mode, /R and /W to control retries and wait times, /LOG to write output to a file and /XO to exclude older files. It also explains exit codes, where a value of 8 or higher indicates at least one failure.

03

Copy vs mirror

Copying with /E adds new and changed files to the destination but never deletes anything there. Mirroring with /MIR makes the destination an exact copy of the source, which includes /PURGE and therefore deletes files in the destination that no longer exist in the source.

Mirroring keeps backups tidy, but if you accidentally delete a file in the source, the next mirror run deletes it from the backup too.

04

Choosing the safer option

For most personal backups, start with /E so deleted files remain in the backup. If storage becomes a concern, consider mirroring with an extra safety net, such as a second backup that keeps older versions, or File History, which keeps versions over time.

05

Retries and wait times

By default, Robocopy retries failed copies many times with long waits, which can make a backup appear stuck when a file is locked. Set sensible values, such as a few retries with short waits, using /R and /W. Files that still fail are logged so you can check them.

06

Restartable mode

The /Z option lets Robocopy resume large file copies if they are interrupted, which helps with network drives and very large files. It can be slightly slower for small files, so use it where interruptions are likely.

07

Writing logs

Use /LOG to save the output to a file, or /LOG+ to append to an existing log. Logs show which files were copied, skipped or failed. Adding /TEE also shows output on screen while logging, which helps when testing.

08

Excluding files and folders

Use /XF to exclude specific files or patterns and /XD to exclude folders, such as temporary folders, caches or large downloaded AI models you can download again. Excluding unnecessary data makes backups faster and smaller.

09

Testing with a list-only run

The /L option lists what Robocopy would do without copying or deleting anything. Always run new commands with /L first, especially when using /MIR, and read the output carefully. This is the simplest way to avoid accidental deletions.

10

Creating a backup script

Save your Robocopy commands in a batch file or PowerShell script. Use full paths for source, destination and log files. You can include several commands for different folders, each with its own log. Add a line that records the date and time so logs are easy to read.

11

Handling exit codes

Robocopy’s exit codes summarise the result. Codes below 8 indicate that the run completed, with values showing whether files were copied or extra files found. Codes of 8 or higher mean at least one failure. Your script can check the code and write a warning to a log or show a notification if something failed.

12

Scheduling with Task Scheduler

Create a task in Task Scheduler that runs your backup script daily at a time when the PC is usually on but idle. Use full paths, choose the right user account and decide whether the task may wake the computer. Test the task by running it manually first.

13

Choosing a destination

Back up to an external drive, a second internal drive or a network location. A backup on the same drive as the original does not protect against drive failure. For important files, consider keeping an additional copy off-site or in a cloud service.

14

Backing up AI work

If you use local AI tools, back up your outputs, custom configurations, prompts and scripts rather than downloaded models, which you can download again. Excluding model folders saves a lot of space and time.

15

Checking backups regularly

Open the backup destination occasionally and confirm that recent files are present and open correctly. Read logs for errors. A backup you have never checked might not be working when you need it.

16

Restoring files

To restore, copy files from the backup back to their original location, either with File Explorer or another Robocopy command in the opposite direction. Test restoring a few files so you know the process works before you need it in an emergency.

17

Sample folder plan for backups

A simple plan is to back up Documents, Pictures, Desktop and a folder for project work, each with its own Robocopy line and log file. Exclude temporary folders and downloaded AI models. Run the script daily to an external or second drive and keep a monthly copy in a separate dated folder. This plan protects everyday work while keeping backups manageable.

18

Backing up to a network drive

If you back up to a network share, use the full network path and make sure the account running the scheduled task has permission to write there. Network interruptions are more common than local drive errors, so restartable mode and sensible retries are especially useful.

19

Keeping the script readable

Add a comment above each Robocopy line describing what it backs up and why certain options are used. Months later, these notes make the script easy to update.

20

Common mistakes

Mistake

Using /MIR without testing.

Better

Run with /L first and understand that /MIR deletes extra files in the destination.

Mistake

Leaving default retry settings.

Better

Set short retries with /R and /W so backups do not stall.

Mistake

Never checking logs or exit codes.

Better

Review logs and treat codes of 8 or higher as failures.

21

Common questions

Is Robocopy built into Windows?

Yes. It is included with Windows.

What does /MIR do?

It mirrors the source, including deleting files in the destination that are not in the source.

How do I test a Robocopy command safely?

Add /L to list what would happen without copying or deleting.

What exit code means failure?

A code of 8 or higher indicates at least one failure.

22

Multithreaded copying

Robocopy can copy several files at once with the /MT option, which can speed up backups of folders with many small files, especially to fast drives. Use a moderate thread count, since very high values can slow down other work on the PC. Test the setting to see whether it helps on your hardware.

23

Backing up only recent changes

Because Robocopy skips files that are already identical in the destination, daily backups after the first one are usually quick. Only new and changed files are copied. This makes daily scheduling practical even for large folders, as long as the first full copy has completed.

24

Keeping several backup versions

Robocopy keeps one copy of each file. If you want to keep older versions, you can create dated backup folders for weekly or monthly copies, or combine Robocopy with File History. Multiple versions protect against files that were damaged or changed by mistake before the backup ran.

25

Notifications for failures

If you want to know when a backup fails, your script can check the exit code and create a notification, write a warning file to your desktop or log the problem somewhere you check daily. A failed backup that nobody notices gives a false sense of security.

26

Using AI to help write the script

An AI assistant can help draft a backup script with logs, exclusions and exit code checks. Describe your folders, destination and whether you want copying or mirroring. Then review every option, test with /L and run it on a small folder before scheduling it for your important data.

27

The bottom line

Robocopy and Task Scheduler give you a free, reliable daily backup system on Windows. Start with /E for safety, use /L to test, set sensible retries, write logs and check exit codes. Schedule the script, back up to a separate drive and test restoring files so you can trust your backups when it matters.

Recommended for You