Skip to content

Quick XCOPY Backup Script

If you find yourself needing to copy a folder regularly but think that a full fledged backup system is too much, this simple script will copy that folder to another location and include a YYYYMMDD-formatted date at the end.
The Batch File Script

Set _Today=%date:~10,4%%date:~4,2%%date:~7,2%
xcopy "<Folder to Copy>" "<Destination>\<FolderName>_%_Today%" /e /v /i /h /r /y

Just replace <Folder to Copy> with the path to the folder you want to copy (don’t include a trailing backslash), <Destination> with the path to your backup area (yes, network paths work just fine), and <FolderName> should probably be the same name as the folder you’re copying. For example:

Set _Today=%date:~10,4%%date:~4,2%%date:~7,2%
xcopy E:\MinecraftServer\newworld E:\MCBackups\newworld_%_Today% /e /v /i /h /r /y

This copies my Minecraft server’s world data into a backup folder, with each day’s backups being named something like newworld_20111113.

Save this as a batch file somewhere that the user who will be doing the backups has permissions to access.

In order to make this run regularly, go to Task Scheduler and have it run the batch file as often as you need.

Published inTechnology