[GUIDE] Creating backups on compile

Idolon

they/them
aa
Feb 7, 2008
2,105
6,106
Accidents happen, and sometimes you'll end up with a corrupt .vmf. There's a lot you can do to combat this: use Hammer's autosave feature, regularly save your map under a new filename, and so on. However, all of these rely on you being consistent, and if you're like me, you just aren't.

Another step you can take is creating a backup on every compile. This can be accomplished through either Hammer's Expert Compile menu or CompilePal, and it doesn't require much additional effort from you once you set it up - it just duplicates the .vmf every time you compile.

Here's how:

1. Open the compile window (F9). If you aren't already using Expert Compile, It should look like this:

XTdpeTa.png


2. Click "Expert..." in the bottom left to open the Expert Compile menu. You'll find this scary looking interface:

93zClZM.png


3. This menu works by executing a series of commands in order, which are shown in the menu on the left. We're going to add a command by clicking "New." It should add a blank entry to the list at the bottom, which you can move to the top by highlighting this option and clicking "Move Up" a few times.

Jbi4pJp.png


4. Now we want to configure this command with the menu on the right. Click "Cmds" and choose Copy File.

f1lSuC2.png


5. Now we're going to enter "$path\$file.vmf $path\$file.backup.vmf" into the Parameters menu (without quotes). This tells the Copy File command to duplicate your .vmf file into the same directory, but change ".vmf" to ".backup.vmf." (You can change if you'd like your backups to be named differently or if you'd like them to be saved to another folder.) Ultimately, your window should look like this:

aSGKkML.png


6. You'll need to copy this command to all of your configurations so that it happens all of the time. You might also find it helpful to make an additional configuration that just creates a backup without actually compiling a .bsp.

Note that this method requires that you use Expert Compile for all of your compiles, since you can't configure the simple compile menu to do this. Hammer already comes with a number of configurations that should suit most of your needs, so this isn't that bad - its just a little less friendly looking.

Download the attached "compilepal-backup.zip," and extract it to your CompilePal folder.

It contains a backup.exe that should appear in the same folder as CompilePalX.exe, which is the program that actually copies files on compile. Also contained is a new Parameters folder that will replace your existing files, which is what will add a "BACKUP" command to CompilePal.

You'll need to open "backup.meta" (with Notepad or something similar) in the Parameters folder and replace "C:\Source\Backups" with whatever path you want your backups to be stored at.

The next time you launch CompilePal, there should be a new command:

h3NGrI9.png


Credit for all of this goes to Fubar, who made all of these files and helped me set them up. Thanks dude!
 

Attachments

  • compilepal-backup.zip
    6.4 KB · Views: 268

Hyperion

L16: Grid Member
aa
Jun 8, 2015
840
659
While we are at it, how can one save compile options? Sometimes those just reset
 

Werewolf

Probably not a real Werewolf
aa
Apr 12, 2011
873
309
While we are at it, how can one save compile options? Sometimes those just reset
Compile settings are stored in the "CmdSeq.wc" file, which itself is located in the bin folder (Steam\SteamApps\common\Team Fortress 2\bin\CmdSeq.wc)

Personally I have batch file set to copy that file (along with other files) to my backup location (my external HDD) and that batch file runs every time I boot up my PC. Then whenever TF2 updates and those settings revert to default, you just need to copy the CmdSeq.wc back from your backup location to the bin folder.
 

Crash

func_nerd
aa
Mar 1, 2010
3,315
5,499
Compile settings are stored in the "CmdSeq.wc" file, which itself is located in the bin folder (Steam\SteamApps\common\Team Fortress 2\bin\CmdSeq.wc)

Personally I have batch file set to copy that file (along with other files) to my backup location (my external HDD) and that batch file runs every time I boot up my PC. Then whenever TF2 updates and those settings revert to default, you just need to copy the CmdSeq.wc back from your backup location to the bin folder.

The trick @Egan taught me was just zipping it right in that folder, which you can just unzip in place if you ever need to reverify your game cache.