How to create a batch file that can be used to automatically back up your projects

If you don’t have some fancy backup program on your computer, but you’re too lazy/forgetful to constantly back up your projects, you can create a program to backup its directory to a different location using the long dead art of .bat files and scheduled tasks.

1. Create a new text file called whatever you want, and rename its extension to .bat then right click and click edit, and it should open it up in notepad for you.

2. For those who have no experience with these kinds of things, make sure you put each command on one line, and only one command per line.
Now add on the first line (this is optional but looks good in the log file more on that later):

@echo off (to stop it from showing the following message twice)
ECHO Backing Up Your Game Now... >> Log.txt

This will cause it to show Backing Up Your Game Now… in the command line. We will be adding >> Log.txt to the end of many of these commands, as it will cause it to create and edit a log file so you can see what it has done. Feel free to change it to specific game name whatever.

3. Now for the actual copying part.

@echo on
XCOPY "Your Project Directory i.e. C:\whatever" "Backup Directory for Project i.e. D:\Backup Projects" /S /Y >> Log.txt

The /S parameter causes it to copy all subfolders/files. /Y causes it to overwrite without prompting you. In the Log.txt file it will show the names of all copied files and the total number copied.

4. More stuff for log file:

@echo off
echo Successfully Backed Up Your Game >> Log.txt

echo @prompt set date=$d$_set time=$t$h$h$h > {a}.bat
%comspec% /e:2048 /c {a}.bat > {b}.bat
for %%v in ({b}.bat del) do call %%v {?}.bat
echo %date% %time% >> Log.txt

Will show exact date and time at the end of each entry.

echo. >> log.txt (adds blank line into log file to stop entries from running together)
5. Save and Close, then test it to see if it copies everything and creates the log file.

6. If it works, which it should, go into your scheduled tasks in the control panel and make new tasks for your backup.bat file(s) for however often you want them to backup. Daily or whenever the computer is turned on could be a good idea if you work on them often, but bi-weekly or something might suffice. Just make sure that you set it to times the computer is likely to be on and your backup drive stays connected!

Backing up your projects is an important thing to do. Hopefully this will make it even easier for you.


Pages: 1
Sounds pretty cool but i stick to my usb.
This is awesome, I have a 500 gb external HD that I'm supposed to back up my stuff on but never do cuz it's annoying. This will make it so much easier. Thanks!

And demondestiny: This makes it easier for you to handle your usb. Just plug it in and double-click the bat file and the files will copy themselves. No need for you to browse around in the usb device to find the folder where you store the backup etc.
Returning from RMVX Death
Ok, whenever I did this and looked in my Log.txt file, I got this in there:

Backing Up your Game Now...
0 File(s) copied
Successfully Backed up Your Game
Fri 08/07/2009 15:38:35.45

Does it mean that it did not copy anything or there was nothing to copy?
Not sure I understand...
That means that it did not copy anything. Make sure that you didn't add an extra backlash behind the directories, i.e "C:\Games" not "C:\Games\"
Pages: 1