How-to-do Guide: Batch File to Backup Files to Network Drive

If you want to use batch files to backup or sync files from local drive to network drive, you can follow below stepwise guide to do.

By @Maggie Last Updated December 12, 2023

What is batch files?

Batch files, identified by the .bat extension, is a script file containing a series of command lines executed by the Command Prompt. It's commonly used for 'batch processing,' automating routine tasks to eliminate repetitive manual actions. Namely, the existence of which eliminates the tedious backup operations when there are a number of small files which are frequently modified and you want to keep the latest copy.

If you have crucial data that requires regular backup, a batch file offers a practical solution.

 

I am trying to create a backup of some local files on one machine, to a networked hard drive on another machine. The source computer is running Windows Server 2008 R2, and the destination machine is running Windows Server 2003 R2. I want to create a batch file that will run on the source computer, and copy all of the files in the D:\MICROS folder to a separate network drive. \marketing\TeraByte\marketingdata\MICROS\TESTBKUP\ is where the files will need to end up. The batch file will be executed through the task scheduler and should run regardless of whether or not a user is logged in. I tried to make the batch file myself, and this was the best I could come up with.

- Question from {Microsoft Community}}

In the upcoming article, I'll guide you through the detailed steps to create batch file to backup files to network drive. If you find this approach complex or not flexible enough, an alternative is to use third-party backup and restore software. This not only simplifies the process but also offers comprehensive and flexible functionality, including image backup and file sync.

I'll cover both methods in the following article, allowing you to choose the approach that best suits your needs.

How to do: copy files to network drive batch file

Here you have two ways to create batch file to backup files, follow me to continue.

Way 1. Create batch files via Robocopy

Start by using commonly used command lines for copying files and folders, such as Xcopy and Robocopy. For more advanced capabilities, let's use Robocopy in this instance.

Step 1. Right-click on the desktop, select New -> Text Document to create a .bat file using a text editor like Notepad.

Step 2. Open the text document and input the command, specifying source and destination directories as needed.

robocopy C:\test \\Bf-202106171848\d:\test

Note📝: To customize file copying, various switches can be added. Check the complete list of Robocopy parameters for reference. Some useful parameters include: /s to copy subdirectories and exclude empty directories /xo to exclude old files /mov to move files to another folder while removing them from the source folder

If you want a notification after copying a file and the ability to press any key to exit, use the echo and pause commands. Example: @ECHO OFF ECHO Copy completed! robocopy C:\test \\Bf-202106171848\d:\test/s /z PAUSE

🌟Tip: This script displays "Copy Complete" after copying to the target directory. The Command Prompt window pauses until any key is pressed.

Step 3. Save the file by clicking File -> Save As…, give it a name, and change the extension from .txt to .bat. This creates a batch file that you can double-click to run the command.

Way 2. Create batch files with Task Scheduler

Step 1. Press Windows + S to open the search box, then type and open Task Scheduler.

Step 2. On the main screen, choose Create Basic Task… and follow the wizard to make your selections.

Step 3. Enter a task name and description, then choose the task trigger. For a daily file copy to a network drive, select Daily and set the specific time to auto backup batch file.

Step 4. Choose how the task should be performed. Opt for Start a program and browse for the .bat file you created.

Step 5. Check the box that says Open the Properties dialog box for this task when I click Finish. After confirming settings, click Finish.

Step 6. Note that the Task Scheduler can access the mapped network drive only if the "Run only when user is logged on" option is enabled. If you want automatic file copying to a network drive, ensure this option is selected in the Properties window.

An easier way to backup files from local to network drive✨

While the combination of Robocopy and Task Scheduler offers flexibility for various purposes, it demands some computer knowledge and can be slightly intricate to operate. For a more user-friendly solution with equally robust data protection features, consider trying AOMEI Backupper Standard.

This free software is compatible with Windows 11/10/8.1/8/7/Vista/XP. It enables seamless file copying between internal/external disks, flash drives, network locations, and cloud drives. With AOMEI Backupper Standard, you can effortlessly copy local folders to the network, transfer network folders to cloud services like Google Drive or OneDrive, and even synchronize folders between different computers.

>> For backup: You have the flexibility to choose between files & folders, partitions, disk, or the entire OS for your backup. The default backup method is Incremental, which selectively backs up only the changed files since the last backup. This not only saves considerable backup time but also optimizes disk space usage. >> For sync: You have the option to specify particular files or folders. If you decide to upgrade to the Professional edition, you'll unlock advanced sync modes such as Real-Time Sync, which triggers automatically upon detecting any data changes. Additionally, you can explore Mirror Sync, ensuring files on the destination path match exactly with the source path, and Two-Way Sync in the advanced version.

Now download AOMEI Backupper Standard and install it on your computer.

AOMEI Backupper

Best free Windows backup & sync software for personal use.

Way 1. Use backup function

Step 1. Open this software and choose Backup > File Backup.

Step 2. Click Add Folder or Add File to select the source data.

Step 3. In the second column of the same page, click on the inverted triangle to choose Select a network location and fill in the network location as required.

Step 4. (Optional) You can click the Schedule icon to set the backup frequencies in daily/ weekly/ monthly/ event-triggers and USB Plug-in mode as you need.

Step 5. Then choose Start Backup to execute.

Way 2. Use sync function

Step 1. Open this software and go to Sync > Basic Sync.

Step 2. Click Add Folder to select the folder you want to copy to the network drive.

Step 3. Then click the inverted triangle button below to select the destination path, click Select a network location to add your network drive path.

Step 4. Next, click Schedule to set up automatic file copying. You can choose daily, weekly, monthly, and event triggers, USB plug-in.

Step 5. After you have determined all the settings, click Start Sync.

★ How to backup files to AOMEI Cloud The rising trend in file backup is leaning towards cloud storage. If you have an AOMEI account, you can seamlessly back up files to AOMEI Cloud. Upon signing up, you'll enjoy 1TB of free storage for the first 15 days of your AOMEI account.

Conclusion

After reading this article, you know 2 methods to create batch files to backup files to network drive, namely using Robocopy command and Windows Task Scheduler.

However, setting up automatic file-copying tasks using these tools can be a bit intricate. That's why I recommend using the user-friendly and free backup software - AOMEI Backupper to streamline the task. Its straightforward operation makes it accessible even for users with limited computer knowledge.

AOMEI Backupper not only facilitates faster file transfers to different locations but also enables disk or system cloning. This proves invaluable when upgrading your computer's hard drive. Cloning a disk with a system ensures a seamless boot experience from the cloned disk, free from any issues and data loss.