Perform Auto Backup with Batch File in Windows 10 (2 Ways)


What is batch file? Can you use it for backup?

In Windows 10, a batch file is a script file (with .bat extension) consists of a series of command lines that executed by Command Prompt. Usually, you can use it for “batch processing”, e.g. automating everyday tasks to avoid repetitive manual operation. So if you have some important data to back up regularly, the batch file is a considerable solution.

In the following article, I will introduce the detailed steps to create backup batch file in Windows 10. If you find it complicated or not flexible enough, you can also use a GUI-based file backup solution to automate the backup task - it not only makes the process easier, but also provides more comprehensive functionality to backup files in Windows 10, such as image backup and file sync.

I will cover both methods in the following article, just pick the one that suits you best.

backup batch file windows 10

How to create backup batch file in Windows 10

First, you need a text editor to input the backup commands and save it with .bat extension. Thus every time you double-click the script file, these commands will be performed automatically. Furthermore, you could use Windows Task Scheduler to run the task on regular basis.

Among the commands that apply in this case, copy is for files only while xcopy works on both files and folders, so the latter is more popular. Also, there’s robocopy that functionally replaces xcopy and provides more options.

xcopy batch file

Please note: You could use batch file to copy (or synchronize) important files & folders as a backup, but none of the commands could create image backup, neither can it keep different versions of data for accurate recovery. If you have further backup needs, please refer to the next method.

Way 1: Create batch file to backup files in Windows 10 step by step

1. Open Notepad. You could search it on taskbar, or right-click on the desktop, choose New > Text Document to create a new text file.

2. Now you can type the backup script. If you want any text to be displayed after the operation is completed, enter the following lines:

@ECHO OFF
ECHO [Any text you want]
PAUSE

*“PAUSE” ensures the window will open after executing the command. Otherwise it will close as soon as the script finishes running. You can use it at the end of the script.

Then, insert the backup command before “PAUSE”. If you want to create backup batch file with xcopy, the basic command is: xcopy [source] [destination]

You can add any switch you need as following:

/f Displays source and destination file names while copying.
/u Copies files from Source that exist on destination only.
/s Copies directories and subdirectories, unless they are empty.
/e Copies all subdirectories, even if they are empty.
/t Copies the subdirectory structure (that is, the tree) only, not files.
/h Copies files with hidden and system file attributes.
/z Copies over a network in restartable mode.
/d Copies only source files that are newer than existing destination files.
… Click here to view more parameters.

*Robocopy command-line is also a good idea. Learn more about it in robocopy incremental backup.

I’ll give a simple example here. You could modify it and replace the path as you need.

@ECHO OFF
ECHO Backup completed!
xcopy /f /s /h /d C:\Users\Delia\Desktop\copy D:\copy
PAUSE

It means to copy all the newly changed or added files (including subdirectories and system files) from source to destination. All the file names will be displayed, and the window will open afterward.

3. Click File > Save As, give it a name and change the extension into .bat.

save backup batch file

4. Then you can double-click the script file to have a try.

Way 2: Create auto backup batch file with Task Scheduler

Now that you’ve created a backup batch file, how to automate it? Task Scheduler is the answer.

1. Open Control Panel, view it by large icons or small icons, then choose Administrative Tools > Task Scheduler. Then you can Create Basic Task.

create scheduler task

2. Type a task name and description, then choose how to trigger the task. Frequency and event are both available.

how to trigger the task

3. Choose Start a program and browse your PC to select the .bat file.

start a program

4. After confirmation, click Finish to create the schedule task. You should be able to find it in the Task Scheduler Library afterward.

task scheduler library

Better way for automatic backup in Windows 10

When you use batch file to backup files in Windows 10, you are actually synchronizing them from source to target with original folder structure, and the copied files could be accessed and used directly. However, it will not keep different copies of a frequently modified directory. When you do something wrong with it and the changes have been auto copied to the target directory, it is very difficult to retrieve any previous version.

To fulfill your different backup needs, free backup software like Qiling Disk Master Standard can be a more complete solution. It enables you to sync files with the original format as well as backup them to image files. And either way, you could do a very simple setup to schedule automatic backup or sync.

>> For backup: You could select files & folders, partitions, disk or OS to proceed. Incremental backup is the default backup method, which only backup changed files since the last backup. This saves much backup time and disk space.
>> For sync: You can specify files or folders, and if you upgrade to the Professional edition, you will enjoy advanced sync modes like File Sync, which executes automatically once a data change is detected. Also, you still try File Sync (to keep files on the destination path exactly the same as source path) and Two-Way Sync in the advanced version.

This software supports all Windows PC and various storages like internal/external hard drive, USB flash drive, NAS, network share, cloud. You could arrange the source and target as you like. Download the free version to have a try.

Way 1: Backup files & folders in Windows 10 automatically

1. Launch the software, select Backup and then File Backup to image files & folders. You could also choose other options according to your needs.

file backup

One of the major advantages of Qiling over batch files is that it can auto-detect and back up the full system. Just choose System Backup or Disk Backup when needed. Besides, it still enables you to create a cloud backup with Qiling Cloud, a cloud drive with 1TB of free storage, and you have 15 days of free access after registration.

2. Click Folders or Files to select the source data, and select a destination to store the image file.

Filess folders

If want to backup files from or to a network location, just click on the source or target bar, hit Share/NAS on the popping out window and click Add Share or NAS Devices to specify a path.

3. Click Schedule Backup to set up automatic backup. It ncludes Daily/Weekly/Monthly in Standard version and USB plug in/Event triggers in Pro edition. Then, click Proceed to execute this task.

schedule general options

By default, this software will run Incremental Backup together with the schedule backup task. Although it saves a lot of time and disk space, the backup disk may be fulfilled as well due to limited space.

At this time, you can choose to auto delete backups older than x days with automatic backup cleanup methods. You need to upgrade (5% off for one computer) before using it.

Enable Automatic Backup Cleanup

Way 2: Auto sync folders between 2 directories in Windows 10

1. Go to Backup and recovery tab, choose File Sync to sync changed files from source directory to target directory.

File Sync

In Pro or higher editions, you will enjoy 3 more sync modes. Besides File Sync, there are also File Sync to make the target folder exactly the same as the source folder, and Two-Way Sync to sync any changed files in source or target folder to the other side.

2. Click Folder to specify one or multiple folders you want to sync.

Folders

3. Similar to backup, you can set up a Schedule Sync here to perform file copy automatically.

schedule sync

For File Sync, you don’t need to create a schedule. It will run automatically once the change is detected.

4. Click Proceed to execute the task.

Conclusion

Creating backup batch file in Windows 10 could simplify and automate the process, especially when you want to perform the same tasks regularly. But if you want more complete backup modes with simple operation, Qiling Disk Master is a reliable choice.

It enables you to Sync (copy) or Backup (image backup) files as you like and create a schedule to automate it very easily. In addition, the Clone features also allows you to clone hard drive to SSD. Even if you are a Windows Server user, there’s a specialized Server edition to suit your needs.

Related Articles


Is this information helpful?     

What can we do to improve this information? (Optional)
Refresh Please enter the verification code!