MoonPoint Support Logo


Shop Amazon Warehouse Deals - Deep Discounts on Open-box and Used ProductsAmazon Warehouse Deals

Advanced Search
Sun Mon Tue Wed Thu Fri Sat
Oct Dec

Mon, Oct 24, 2022 10:10 pm

Daily Backup Using Robocopy

I wanted to use Robocopy, to backup a directory on a Windows Server 2022 system to an external USB drive attached to the server every weekday. The server is at a company where employees don't usually work on files at the office on weekends and I create a weekly backup archive on weekends using a different backup method. I opted to use Robocopy since it is a free command-line utility for replicating files and directories that is provided by Microsoft with current Windows operating systems. The directory I want to backup is D:\ACCI and I want to create the backup on the external E:\ drive in the existing directory E:\ACI\Backups\ACCI. I want that backup directory to always mirror the source directory, so any files added during the day should be added to the backup directory when the Robocopy command runs and any files that are deleted from the source directory during the day should be deleted from the backup directory when the Robocopy command runs. I.e., the backup directory should mirror the source directory, so I use Robocopy's /MIR option. The source directory is a directory shared over the local area network (LAN) and it is possible that an employee may leave for the day with one or more files in the shared folder on the server still open. I don't want Robocopy to wait and try again to backup an open file since the script will be running at night at a time employees aren't likely to be still working and so any file that is locked because it is still open will likely remain open until at least the the next day when employees resume work. So I use the /W:0 option to tell Robocopy to immediately retry to backup a file if it encounters a problem (by default it will wait 30 seconds and try again) and the /R:1 option to tell Robocopy to only retry backing up a file once rather than try repeatedly (it will try 1 million times by default). I want to record all output of the Robocopy daily backups in E:\ACI\Backups\RoboCopyBackup.log so I place that output path and filename after >> which will append the daily output to that file—if you just use one greater than sign rather than two, the file will be overwritten each time the Robocopy command runs. So I have the following Robocopy command, which I placed in a file I created with Windows Notepad named Robocopy_Daily_Mirror.bat (when you are saving a batch file in notepad change "save as type" from "Text Documents (*.txt)" to "All Files"):

robocopy D:\ACCI E:\ACI\Backups\ACCI /MIR /W:0 /R:1 >> E:\ACI\Backups\RoboCopyBackup.log

[ More Info ]

[/os/windows/utilities/backup/robocopy] permanent link

Once You Know, You Newegg AliExpress by

Shop Amazon Local - Subscribe to Deals in Your Neighborhood

Valid HTML 4.01 Transitional

Privacy Policy   Contact

Blosxom logo