Jump to content

Recommended Posts

Since backups came up in another thread I thought I would share my backup scripts. I thought I had done this in the past but I did a search and came up empty.

I wrote these scripts years ago and have been using them for scenario design, mod design and programming projects. The basic principal is to zip up a directory and copy it to a backup location (keeping old versions) and a second location. This lets me know I have the last 10 versions and the second copy allows me to move my work between computers. I used to use a USB stick (hence the command line option "portable") but now I use drop box. I hope others can benefit from these scripts feel free to modify and enhance them as you wish.

Dependencies:

  • Winzip and
  • WinZip Command Line Helper.

I currently use WinZip 20.0 and WinZip Command Line Helper 4.0. I have used older versions so my scripts do not need the latest but they do need those two things to be compatible. Changing to  use a different .zip utility would be a one line change for the command line and two other lines to make the batch variable name match a different tool.

With those in place you can unzip the backup command and an example usage from here: https://www.dropbox.com/s/ifzujn77afk1ei3/BackupExample.zip?dl=0

In there are two .cmd files. The first is BackupToZip.cmd It is the generic backup utility that preserves the last 10 versions and optionally makes a second copy of the most recent backup. When you run it you see the following command line usage guide:

C:>p:\BackupToZip.cmd
BackupToZip zipname backuppath pattern [-portable path] [other zip options]
Press any key to continue . . .

  • zipname is the name of the file you want to create
  • backuppath is where you want to place the backup copies
  • pattern is what to backup
  • portable path is an optional location to place a second copy
  • other zip options lets you pass other command line options to winzip (or what ever other .zip utility you might swap in) these are passed as it to the winzip command

Rather than typing a complex command line every time I want to backup my work I create a project specific backup .cmd file. An example of which is included in the above .zip file. This is the script I used while I was working on the Lanzerath ridge scenario:

@echo off
call P:\BackupToZip LanzerathRidge P:\Backups D:\Users\IanL\Documents\Battlefront\COMBAT~1\Bulge\GAMEFI~1\WorkInProgress\LanzerathRidge\*.* -portable D:\Users\IanL\Dropbox\ScenarioWork -x*.class

What that does is copy the entire (*.*) contents and sub folders of my WorkinProgress\LanzerathRidge folder to a .zip file named LanzerathRidge in a Backups directory (also saving the last 10 back up .zip files) and make a second copy on Dropbox under a folder named ScenarioWork. The -x*.class is a left over from a java project backup script that I copied to create my LanzerathRidge backup file. Oops my bad. Just ignore that. If you cannot ignore it here is the explanation: it serves as an example of passing additional zip command line options through. I never backup .class files in a Java project since those are the compiler's artifacts and there is no value in saving them since they are derived from the source files.

I create a WorkInProgress directory under the Game Files directory and under there I have a sub folder for each thing I'm working on. Then I create a Backup<ScenarioName> command line script to back it up. Under that sub directory I have all my notes, links, briefing text files and graphics files as well as the scenario itself.

You might have noticed that I am not using paths with spaces this is simply because I never did the work to support that. In my development projects I never use spaces in directory names and this backup script was initially created for backing up programming projects. There was just no need. When I moved to use it for Combat Mission purposes I just didn't spend any time changing that since I can just feed the scripts the old 8.3 directory names.

Yes, that looks sucky.

Yes, it means you have to do an additional step when you create your backup script

No, I'm not going to be changing that - but you could if you want :D

You can always find the 8.3 directory name by using these command line arguments with the dir command in any command shell:

dir /X

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...