Click here to Skip to main content
Click here to Skip to main content

Automated Source Safe Backups

By , 20 Feb 2001
 

Automated Source Safe Backups

Recently I became tired of manually backing up a source safe database by going into the source safe administrator and going through the manual backup procedure. I decided to automate the process.

Goals

1. Automate the process so it occurs once a day.
2. Generate backup files that are identified by date (ie. '08-20-2000 Project Backup.ssa').
3. If possible don't resort to using any programs other than the built in NT utilities.

**NOTE!**

I solved these problems on Windows 2000 and everything works fine using the steps below. On windows NT 4 however there is one major problem, the 'at' utility for scheduling operations would not work for me, I tried it on several different computers and even though it appeared to schedule an operation it just would not run it when the time came. The exact same commands that work on windows 2000 do not work on NT 4. If someone knows how to get 'at' working then I would appreciate it!

Step 1

Create a batch file with the following text.

@ECHO OFF
@TITLE Backing up source safe databases<br>
FOR /F "tokens=2-4 delims=/ " %%i IN ('date /t') DO SET DATE=%%i-%%j-%%k
e:\source_safe-code\win32\ssarc -d- e:\backups\%DATE% General backup.ssa $/General
@ECHO Finished backups

Replace 'e:\source_safe-code' with the location of your source safe database directory.
Replace 'e:\backups' with the directory that you want to place the backed up projects into. 
*NOTE* if your source safe data is kept in a different directory than the 'data' directory inside of source safe you will need to tell ssarc this. Look up the documentation in the MSDN (see Further Reading at the bottom of this document)
Replace 'General backup.ssa' with the name of the file that you want to save the backups to (the file will be saved in the format '8-2000-99 name.ssa')
Replace the 'General' after the '$/' with the name of the project that you want to backup or just put '$/' to backup everything.

Save this batch file somewhere, I used the name 'ss_backup.bat'. Test the batch file by running it from the command line.

I'll explain the workings of the batch file later.

Step 2

To automate the running of the batch file I used a utility that comes with NT and 2000 called 'at'.

Make sure that the 'Schedule' service for NT or 2000 is running by going to the control panel->Services and finding the 'Schedule' service Make sure to set it up to startup automatically, otherwise when you reboot it will not be active.

Go to the command prompt and enter the command 'at'. If everything is going ok this should give you a list of recurring processes already set up (it may be an empty list).

Enter this command line, it will schedule the backups using the batch file you created earlier:

at 05:00:00 /interactive /every:M,T,W,Th,F,S,Su cmd /c e:\ss_backup.bat

Replace 05:00:00 with the time that you want to run the process.
Replace M,T,W,Th,F,S,Su with the times that you want to run the backups.
Replace e:\ss_backup.bat with the location that you saved the batch file from step 1.

Final Step

You should now be all set to go. The backups will be put into the directory that you specified and will take place. I have the backups taking place on a daily basis and then at the end of every week I archive the backups to CD. I Also added another line in the batch file that copies the backed up file to a remote drive for added redundancy.

It is probably also a good idea to add a periodic job to analyze the source safe database for errors. I have had inconsistencies in the database before, and it is a good idea to monitor for problems. Microsoft recommends running the analyze utility once a week. You can find more information at http://msdn.microsoft.com/library/techart/vssbest.htm. Make sure that no one is logged in and using the source safe database before running the 'analyze' utility! You can use the -x parameter for analyze to force users out.. but Microsoft does not recommend this.

Explanation of Batch File

The batch file is pretty simple. The only line that requires much explanation is:

FOR /F "tokens=2-4 delims=/ " %%i IN ('date /t') DO SET DATE=%%i-%%j-%%k

'FOR' is a built in NT/2000 command that allows you to process the output of file listings and text listings. The '/F' flag tells 'FOR' to process the immediate output of the command that is run, in this case the output of of 'date /t', which is the current date. 'tokens=2-4' tells 'FOR' to tokenize the output of date /t and grab tokens 2 through 4 and put them into variables starting at %%i (so the tokens can be referenced as %%i. %%j, %%k etc..) . The stuff after DO is executed after the tokenizing is finished and it assigns an environment variable 'DATE' with the tokens with dashes in-between them. In this case the tokens are the month-day-year.


This line also needs a little explanation

e:\source_safe-code\win32\ssarc -d- e:\backups\%DATE% General backup.ssa $/General

ssarc is the command line backup utility that comes with source safe, it is installed by default in the 'win32' directory of source safe. -d- tells it not to delete any of the files that it is backing up. The parameter after that is the name of the output file and the next parameter is the name of the SourceSafe project to backup.

@TITLE sets the title of the command line box that is created when this batch file is run.

Further Reading

Documentation for all of the source safe command line tools is available in the MSDN under Visual Studio Documentation -> Visual Source Safe Documentation -> Reference Guides -> Using the VSS command line.

http://msdn.microsoft.com/library/techart/vssbest.htm

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Conor Hunt
United States United States
Member
Visual C++/Java programmer.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
Hint: For improved responsiveness ensure Javascript is enabled and choose 'Normal' from the Layout dropdown and hit 'Update'.
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionVery helpfull, thanksmemberenamur26 Nov '07 - 21:58 
GeneralI use Code Co-op from Reliable Software (VSS == dog)membermatt200028 Aug '07 - 6:39 
GeneralRe: I use Code Co-op from Reliable Software (VSS == dog)membersledhed24 Sep '07 - 11:28 
GeneralPassing the Admin passwordmemberDimondWolfe13 Jun '07 - 11:57 
GeneralRe: Passing the Admin passwordmemberDimondWolfe13 Jun '07 - 12:09 
Generalpressing ctrl-c in the middle of a backup operationmemberSameer Alibhai11 Jun '07 - 11:43 
GeneralPowershell version of automated source safe maintenance/backupsmemberKevin Hammond18 Apr '07 - 10:34 
GeneralRestoremembersaintso31 Jul '05 - 18:13 
GeneralCheck-in comments...membersgoks25 Feb '05 - 19:18 
Generalnice jobmemberTim Kohler1 Feb '05 - 8:28 
GeneralUK Date FormatsmemberJames H12 Oct '04 - 2:32 
GeneralTurn off interactive mode???? -i-sussAnonymous22 Sep '03 - 2:56 
Generaluse inbuilt sheduled task functionalitymemberpanache21 May '03 - 4:06 
GeneralVSS backup over 128 characterssussNemesis_DBA3 Mar '03 - 8:20 
GeneralRe: VSS backup over 128 charactersmemberMahasen Bandara12 Jan '04 - 17:24 
GeneralBackup MethodssussAnonymous6 Aug '02 - 0:57 
Generalvbs versionsussAnonymous25 Jul '02 - 0:00 
GeneralSourcesafe backupsmemberEsther Queen24 Jul '02 - 5:45 
GeneralCopying a project archive to diskmemberAnonymous15 Apr '02 - 8:25 
Generala batch file to put files to floppymemberpooky15 Mar '02 - 4:52 
GeneralSource Safe sharingmembersreejith14 Mar '02 - 2:28 
GeneralRe: Source Safe sharingsussAnonymous14 Aug '02 - 8:54 
In SourceSafe Administrator, Tools, Options, General, make sure Allow Multiple Checkouts is unchecked.   Then enable project security in the next tab.
 
Eideto
Generalremote VSSmemberGuljeet Nagpaul25 Feb '02 - 2:42 
GeneralRe: remote VSSmemberKishore274 Dec '02 - 23:19 
Generalremote VSSmemberAnonymous25 Feb '02 - 2:36 
GeneralVSS Report Utilitymemberkar22 Oct '01 - 12:22 
Questionhow do i limit the versions of VSSmemberMohammed Ubaid19 Oct '01 - 0:06 
AnswerRe: how do i limit the versions of VSSmemberSameer Alibhai12 Jun '07 - 3:16 
GeneralSorce Safe DB formatmemberAlexey Kizilov10 Oct '01 - 2:49 
GeneralIf your database has an admin password...memberPaul Hurley11 Sep '01 - 7:33 
GeneralRe: If your database has an admin password...sussAnonymous7 Feb '05 - 4:15 
GeneralAutomation of VSS maintenancememberJordan Atlas2 Aug '01 - 19:31 
GeneralMultiple SS DB to Backup...memberEd20 Jun '01 - 20:01 
GeneralRe: Multiple SS DB to Backup...memberAshin1 Apr '02 - 21:59 
QuestionVSS Documentation for VC++-Integration?memberUwe Keim27 May '01 - 10:38 
AnswerRe: VSS Documentation for VC++-Integration?memberAnonymous28 May '01 - 11:29 
GeneralFreeware utilitymemberAnonymous11 May '01 - 8:01 
GeneralRe: Freeware utilitymemberPaul Hurley10 Sep '01 - 9:22 
GeneralRe: Freeware utilitysussDavid Hayes2 Oct '02 - 23:57 
GeneralRe: Freeware utilitysussAnonymous3 Dec '03 - 7:02 
GeneralLocation of filesmemberRon6 Apr '01 - 5:00 
GeneralRe: Location of filesmemberConor Hunt6 Apr '01 - 5:18 
GeneralRe: Location of filesmemberRon6 Apr '01 - 5:31 
GeneralRe: Location of filesmemberConor Hunt6 Apr '01 - 5:44 
GeneralRe: Location of filesmemberron6 Apr '01 - 10:18 
GeneralRe: Location of filesmemberegilDOTnet20 Jun '01 - 1:55 
GeneralRe: Location of filesmemberAshin1 Apr '02 - 21:51 
GeneralLocking SourceSafe database...membercoriordan28 Feb '01 - 22:05 
GeneralRe: Locking SourceSafe database...memberdtoleary8 Mar '01 - 6:05 
GeneralRe: Locking SourceSafe database...memberpikeboo26 Jul '01 - 3:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130516.1 | Last Updated 21 Feb 2001
Article Copyright 2001 by Conor Hunt
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid