About UsContact Us

 


Users: If you have a Gmail account, you do not need to register; you may login using your full Gmail account username and password.

Home Article Index CM Tools Visual SourceSafe Admin Script
English French German Italian Portuguese Russian Spanish

Member Login

Welcome
Users: If you have a Gmail account,you can use full GMail emaill address as user id and your GMail password.

If you do not wish to use GMail account, please register a new CMCommunity account.



Related Items

Statistics

Members : 4533
Content : 769
Web Links : 7
Content View Hits : 434410

Stats: Our Visitors

Top 10:
United States flag 32%United States
Unknown flag 22%Unknown
Russian Federation flag 10%Russian Federation
United Kingdom flag 4%United Kingdom
Ukraine flag 4%Ukraine
Germany flag 3%Germany
India flag 3%India
Netherlands flag 2%Netherlands
Luxembourg flag 2%Luxembourg
Latvia flag 2%Latvia
Visits from 96 countries
JoomlaWatch Stats 1.2.9 by Matej Koval
| Online Users: 9  |
Hello Guest! If you wish to submit any contents, please login or register.
Visual SourceSafe Admin Script PDF Print E-mail
Monday, 05 December 2005 09:09

 

 

Disclaimer

The free software programs/documentation are provided by assad.ca may be freely distributed, provided that no charge above the cost of distribution is levied, and that the disclaimer is always attached to it.

The programs are provided as is without any guarantees or warranty. Although the author has attempted to find and correct any bugs in the free software programs, the author is not responsible for any damage or losses of any kind caused by the use or misuse of the programs. The author is under no obligation to provide support, service, corrections, or upgrades to the free software programs.

Visual SourceSafe Admin & Maintenance Script


Key Features:

  • VSS Database backups ( 5 latest copies)
  • Auto Locking & folder sharing/unsharing
  • Database analysis and repair
  • Email Notification

Description:
Script performs routine maintenance and visual sourcesafe database backup.A log file listing the output of all actions taken in this script(vssmaintvssmaint-<Date>.log) is generated.If the script is run more than one in one day, the log file is appended.email the logfile to VSS administrator.

A) The VSS database is locked

B) The network drive is unshared and reshared after all task ate complated.

C) If optional argument -copy is provided, copy the data folder as data.bak before analyze utility is exectued.

D) Analyzing the data folder to look for signs of database corruption due to network or operating system problems and fixing the errors (using VSS Analyze utility). The Analyze utility is exextued up to three times (if any problem found) to correct problems. (Analyze utility generates its log info in databackupanalyze.log,which is also copied to a log file generated by this script)

E) Archiving the database (using SourceSafe achieve utility).
If Archive switch is active (file archive_on is present) do archive otherwise skip. Latest 5 copies of previous archive files are maintained on local drive. It would be wise to have weekly tape backup incase the local drive failure. The root folder where the backups are stored is ..archivebackups and each archive file is stored in a seperate folder named as backup.bak0... backup.bak5, where backup.bak0 folder contains the latest.

F) Cleaning the "Temp" folder (VSS usually places files in its Temp folder while running, and deletes them before quitting. Some circumstances, such as having to restart, can cause files to remain in the Temp folder a waste of disk space). Empty the temp folder (path specified in srcsafe.ini)

G) Send emails or Net Send Notification to Administrator and attach log files as body.

Download:

  VSSMaint.cmd VSS Maintanence Script (Core)
  Net.exe Windows Utility , You should already have it as it comes with windows OS
  BMAIL.exe Open source SMTP mailing utility)
  rmtshare.exe NT Resource kit
  run_archive_on Zero byte file acts as a switch.
  sendemails_on Zero byte file acts as a switch.

Installation:

The scripts uses the following utilities in addition to VSS standard utilities, ensure you have the utilities otherwise download it from assad.ca

RMTSHARE.exe (NT Resource kit)
NET.exe utility (windows) OR BMAIL.exe (Open source SMTP mailing utility)

1. Create folder where you want to keep all the scripts (example: C:VSSAdminScripts) and copy the following files.

VSSMaint.cmd VSS Maintanence Script (Core)
RMTSHARE.EXE rmtshare utility
run_archive_on Zero byte file acts as a switch.
  if file run_archive_on esists, perform archieve (backups) along with analyze
  if file run_archive_on does not exist : Do not perform achieve (backups) and only run analyze
sendemails_on Zero byte file acts as a switch.
  if file sendemails_on esists, send email notification to VSS admin and attach logfile
  if sendemails_on does not exist, do NOT send email notifications .
bmail.exe Opensource mail utility

Another file reShare.cmd is generated at runtime by vssmaint.cmd to re share the mapped drive

:: name of shared folder where you vss database resides.
set sharename=vsssharefolderfolder

:: ADMIN NAME or Email addresses if email is sent instead of netsend notification
:: ASSAD=Assad Chaudhry & PETER=Peter
set VSSAdmin=assad
set VSSBackupAdmin=assad
:: ADMIN PASSWORD
set adminpasswd=test
set VSSadminEmail=" This e-mail address is being protected from spambots. You need JavaScript enabled to view it "
set VSSBackupAdminEmail=" This e-mail address is being protected from spambots. You need JavaScript enabled to view it "

:: NAME OF YOUR SMTP EMAIL SERVER
set MailServer=mail.companyabc.com
:: SUBJECT OF EMAIL NOTIFICATION SENT BY THIS SCRIPT
set MailSubject="VSSMaint Script Notification"

:: SOURCESAFE DATABASE LOCATION (LOCAL) & DRIVE
set basedir=C:VSSTestDatabase

:: NAME OF FOLDER OR DRIVE WHERE THE OUTPUT WILL BE STORED (either drive letter or path to a folder)
set OutPutLocation=C:VSSScriptOutput

:: ANALYZE & ARCHIVE PROGRAM LOCATION
set analyzePgm=C:PROGRA~1MICROS~3VSSwin32analyze.exe
set archivePgm=C:PROGRA~1MICROS~3VSSwin32ssarc.exe

When you run the script first time it will create the following folder under the "outputfolder" archivebackups this folder contains backup archivebackupsbackup.bak0 The first back is stored in this folder vssmaint Contains logs files generated during the first run (example archive-04-22-2003.log and vssmaint-04-22-2003.log)

Sample Output (Log Files) & VSSMaint.cmd Script

3:53p
UNSHARING vsssharedfolder
CHECKING DATABASE LOCK
DB IS NOT LOCKED
LOCKING DATABASE
Beginning first ANALYZE
3:53p
ANALYZE.LOG FILE
======STARTING ANALYZE======
Analyze Visual SourceSafe Version 6.0c (Build 9350)
Database analysis in progress @ 4/22/03; 3:53p.
Building the project list.
There are minor inconsistencies in the header flags for 'aaaaaaaa'.
Writing a new copy of 'c:vsstestdatabasedataaaaaaaaaa'.
Checking cross file relationships.
Checking parent/child relationships.
Started analyzing user management system.
Successfully completed analyzing the user management system.
Validating the Security System.
Analysis complete @ 4/22/04; 3:53p
No errors or inconsistencies found.
=======ANALYZE ENDS=======
=======STARTING ARCHIEVE=======
See archieve.log ( C:VSSScriptOutputvssmaintarchive-04-22-2003.log ) for details.
=======ARCHIEVE COMPLETE=======
3:53p
RE-SHARING VSS mqsiqamqsiqa_d
--------------- END OF LOG ENTRY --------------
===============================================

======ARCIVE.LOG START [04-22-2004][3:01p]======
Building project list.
$/
Saving files.
Loading file list
Checking archive file consistency.
Processed 12 files in 0 hours, 0 minutes, and 1 seconds.
======ARCIVE.LOG END [04-22-2004][3:01p]========

 

:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
:: NAME: VSSMaint.cmd
:: DATE: October 20, 2003
:: VERSION: 1.0
:: AUTHER: Assad Chaudhry
:: WEBSITE: www.assad.ca
:: EMAIL: This e-mail address is being protected from spambots. You need JavaScript enabled to view it
:: DESCRIPTION:
::
:: Visual SourceSafe Maintenance Script
:: ====================================
::
:: Script command syntax and options
:: vssmaint [/?][-copy]
::
:: /? : Outputs the Help Section
:: -copy: If optional argument -cOPY is used the following tasks are performed:
:: (a) Make a local copy of the database under data folder.
:: (b) Rename the database backup folder to data.bak0
:: (c) Copy the Database to backup folder data.bak
::
::
:: Script performs routine maintenance and visual sourcesafe database backup.A log file
:: listing the output of all actions taken in this script(vssmaintvssmaint-<Date>.log) is
:: generated.If the script is run more than one in one day, the log file is appended.email
:: the logfile to VSS administrator.
::
:: A) The VSS database is locked
::
:: B) The network drive is unshared and reshared after all task ate complated.
::
:: C) If optional argument -copy is provided, copy the data folder as data.bak before
:: analyze utility is exectued.
::
:: D) Analyzing the data folder to look for signs of database corruption due
:: to network or operating system problems and fixing the errors (using VSS Analyze
:: utility)
:: The Analyze utility is exextued up to three times (if any problem found) to correct
:: problems. (Analyze utility generates its log info in databackupanalyze.log,which is also
:: copied to a log file generated by this script)
::
:: E) Archiving the database (using SourceSafe achieve utility).
:: If Archive switch is active (file archive_on is present) do archive otherwise skip.
:: Latest 5 copies of previous archive files are maintained on local drive. It would
:: be wise to have weekly tape backup incase the local drive failure.
:: The root folder where the backups are stored is ..archivebackups and each archive
:: file is stored in a seperate folder named as backup.bak0... backup.bak5, where
:: backup.bak0 folder contains the latest.
::
:: F) Cleaning the "Temp" folder (VSS usually places files in its Temp folder while
:: running, and deletes them before quitting. Some circumstances, such as having to
:: restart, can cause files to remain in the Temp folder a waste of disk space).
:: Empty the temp folder (path specified in srcsafe.ini)
::
:: G) Send emails or Net Send Notification to Administrator and attach log files as body.
::
:: ============================================================
:: History: DATE VERSION COMMENTS
:: Oct 20,2003 1.0 (Initial Version) Created by Assad Chaudhry
::
:: ============================================================
:: Disclaimer
:: ==========
:: The free software programs/documentation including this script provided by assad.ca may be freely
:: distributed, provided that no charge above the cost of distribution is levied, and that the
:: disclaimer below is always attached to it.
::
:: The programs are provided as is without any guarantees  or warranty. Although the author has
:: attempted to find and correct any bugs in the free software programs, the author is not
:: responsible for any damage or losses of any kind caused by the use or misuse of the programs.
:: The author is under no obligation to provide support, service, corrections, or upgrades to the
:: free software programs.
::
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

@ECHO OFF
if /i %1.==/?. GOTO HELP
::if /i %1.==-help. (
:: GOTO HELP )
::else (
:: set adminpasswd=%1
:: )

:: Capturing and setting Date & Time parameter
FOR /F "tokens=2-4 delims=/ " %%i IN ('date /t') DO SET DATE=%%i-%%j-%%k
For /F %%l IN ('Time /T') Do SET TIME=%%l

@ECHO ON

:: //////////////////////////////
:: //////////////////////////////


set sharename=vsssharefolderfolder

:: ADMIN NAME or Email addresses if email is sent instead of netsend notification
:: ASSAD=Assad Chaudhry & PETER=Peter
set VSSAdmin=localhost

set VSSBackupAdmin=localhost

set adminpasswd=test

set VSSadminEmail=" This e-mail address is being protected from spambots. You need JavaScript enabled to view it "
set VSSBackupAdminEmail=" This e-mail address is being protected from spambots. You need JavaScript enabled to view it "


set MailServer=mail.abcompany.com
set MailSubject="VSS SCRIPT"

:: SOURCESAFE DATABASE LOCATION (LOCAL) & Drive
set basedir=C:VSSTestDatabase

:: Root for admin script , either drive letter or path to a folder
set OutPutLocation=C:VSSScriptOutput

:: ANALYZE & ARCHIVE PROGRAM LOCATION
set analyzePgm=G:PROGRA~1MICROS~3VSSwin32analyze.exe

set archivePgm=G:PROGRA~1MICROS~3VSSwin32ssarc.exe

:: //////////////////////////////
:: //////////////////////////////


set localdatadir=%basedir%data

:: VSS Maintainance Logfiles Folder LOCATION
set vssmaintfolder=%OutPutLocation%vssmaint
:: ARCHIVE BACKUP Folder LOCATION
set arcbackupdir=%OutPutLocation%archivebackupsbackup

:: LOGFILE path (PRODUCED BY THIS SCRIPT)
set logfile=%vssmaintfolder%vssmaint-%DATE%.log
set acrlogfile=%vssmaintfolder%archive-%DATE%.log

 

:: TEMP DIR LOCATION (specified in srcsafe.ini)
set tempdir=%basedir%temp

set vsslockfile=%localdatadir%loggedinadmin.lck
set unlockDB=
set copyflag=
set archiveoff=

if /i %1.==-copy. set copyflag=1
cd /d %~dp0
time/t >> %logfile%

if NOT exist %vssmaintfolder% md %vssmaintfolder%

echo UNSHARING %sharename% >> %logfile%
call :unShareVSS

:: LOCK THE DATABASE
ECHO CHECKING DATABASE LOCK >>%LOGFILE%
if NOT exist %vsslockfile% (
echo DB IS NOT LOCKED>>%LOGFILE%
echo LOCKING DATABASE>>%LOGFILE%
set unlockDB=1
echo.>%vsslockfile%
) else (
echo DATABASE IS ALREADY LOCKED >>%LOGFILE%
set unlockDB=1
)

:: IF OPTIONAL ARGUMENT -COPY IS USED COPY THE DATA FOLDER
if defined copyflag (
ECHO COPYING BACKUPS >>%LOGFILE%
:: make copy of data directory
:: note:verify enough free space
if exist %localdatadir%.bak0 echo DATA.BAK0 EXIXTS - REMOVING FOLDER DATA.BAK0>>%LOGFILE%
if exist %localdatadir%.bak0 rd /s/q %localdatadir%.bak0
:: iF it's a file
if exist %localdatadir%.bak0 echo DATA.BAK0 EXISTS - REMOVING FILE DATA.BAK0>>%LOGFILE%
if exist %localdatadir%.bak0 del /f %localdatadir%.bak0

if exist %localdatadir%.bak echo DATA.BAK EXISTS - RENAMING FOLDER DATA.BAK TO DATA.BAK0>>%LOGFILE%
if exist %localdatadir%.bak ren %localdatadir%.bak data.bak0
:: iF it's a file
if exist %localdatadir%.bak echo DATA.BAK ESISTS - DELETE FILE DATA.BAK>>%LOGFILE%
if exist %localdatadir%.bak del /f %localdatadir%.bak

echo xcoping from %localdatadir% -TO- %localdatadir%.bak>>%logfile%
xcopy %localdatadir% %localdatadir%.bak /e
)

:: RUN ANALYZE
:: -----------

:: Empty or rename the databackup directory. Otherwise, analyze fails.
if exist %localdatadir%backup del /f /q %localdatadir%backup
for %%i in (0 1) do if exist %localdatadir%backup.%%i del /f /q %localdatadir%backup.%%i
for %%i in (0 1) do if exist %localdatadir%backup.%%i rd /s /q %localdatadir%backup.%%i

:::: DOING FIRST ANALYZE
echo Beginning first ANALYZE>>%logfile%
time/t >> %logfile%
%analyzePgm% %localdatadir% -v4 -f -i-
ECHO ANALYZE.LOG FILE >>%LOGFILE%
ECHO ======STARTING ANALYZE====== >>%LOGFILE%
type %localdatadir%backupanalyze.log>>%logfile%
ECHO =======ANALYZE ENDS======= >>%LOGFILE%

:::: if ANALYZE FINDS PROBLEM CONTINUE OTHERWISE GOTO :ARCHIVE
if exist %localdatadir%backupanalyze.log (
find "Found" %localdatadir%backupanalyze.log>nul || goto archive
)
:::: SECOND RUN DOING ANALYZE
echo Errors found. Doing 2nd analyze>>%logfile%
ren %localdatadir%backup backup.0
time/t >> %logfile%
%analyzePgm% %localdatadir% -v4 -f -i- -c -d
ECHO ANALYZE.LOG FILE SECOND ATTEMPT>>%LOGFILE%
ECHO ======STARTING ANALYZE====== >>%LOGFILE%
type %localdatadir%backupanalyze.log>>%logfile%
ECHO =======ANALYZE ENDS======= >>%LOGFILE%

:::: if ANALYZE FINDS PROBLEM CONTINUE OTHER GOTO :ARCHIVE
if exist %localdatadir%backupanalyze.log (
find "Found" %localdatadir%backupanalyze.log>nul || goto archive
)

:::: SECOND RUN DOING ANALYZE
ECHO Errors found. Doing 3rd ANALYZE>>%logfile%
ren %localdatadir%backup backup.1
time/t >> %logfile%
%analyzePgm% %localdatadir% -v4 -f -i- -c -d
ECHO ANALYZE.LOG FILE >>%LOGFILE%
ECHO ======STARTING ANALYZE====== >>%LOGFILE%
type %localdatadir%backupanalyze.log>>%logfile%
ECHO =======ANALYZE ENDS======= >>%LOGFILE%

:archive

if not exist run_archive_on ECHO Archieve Process is bieng Skipped >>%LOGFILE%
if not exist run_archive_on goto UNLOCKVSS


:: ARCHIVE
:: -----------
:: BACKUP OF ARICHIVES
:: Maintain last three archive files as backup
:: arcbackdir = 1st backup, archbackdir.bak = 2nd last backup, archbackupdir.bak0 last backup (3rd)
:: note:verify enough free space

if exist %arcbackupdir%.bak5 rd /s/q %arcbackupdir%.bak5
if exist %arcbackupdir%.bak4 move %arcbackupdir%.bak4 %arcbackupdir%.bak5
if exist %arcbackupdir%.bak3 move %arcbackupdir%.bak3 %arcbackupdir%.bak4
if exist %arcbackupdir%.bak2 move %arcbackupdir%.bak2 %arcbackupdir%.bak3
if exist %arcbackupdir%.bak1 move %arcbackupdir%.bak1 %arcbackupdir%.bak2
if exist %arcbackupdir%.bak0 move %arcbackupdir%.bak0 %arcbackupdir%.bak1
if not exist %arcbackupdir%.bak0 md %arcbackupdir%.bak0

:: RUN ARCHIVE
del /s %acrlogfile%
ECHO =======STARTING ARCHIEVE=======>>%LOGFILE%
ECHO See archieve.log ( %acrlogfile% ) for details.>>%LOGFILE%
ECHO ======ARCIVE.LOG START [%DATE%][%TIME%]====== >>%acrlogfile%

%archivePgm% -d- -c -yAdmin,%adminpasswd% "-O&%acrlogfile%" -s%basedir% %arcbackupdir%.bak0%DATE%-backup.ssa $/

ECHO ======ARCIVE.LOG END [%DATE%][%TIME%]======== >>%acrlogfile%
ECHO =======ARCHIEVE COMPLETE=======>>%LOGFILE%

:UNLOCKVSS
:: UNLOCK DATABASE
if defined unlockDB del %vsslockfile%

:: EMPTY TEMP
:: ----------
rd /s/q %tempdir%
md %tempdir%


:: ADMIN NOTIFICATION
:: ------------------
find "No errors or inconsistencies found" %localdatadir%backupanalyze.log
if Errorlevel 1 (
time/t >> %logfile%
::NET send %VSSAdmin% "VSS Maint Problem. Look at %sharename%databackupanalyze.log or %LOGFILE%"
::NET send %VSSBackupAdmin% "VSS Maint Problem. Look at %sharename%databackupanalyze.log or %LOGFILE%"
echo "VSS Maint Problem. Look at %sharename%databackupanalyze.log">>%logfile%
if exist sendemails_on bmail -s %MailServer% -t %VSSadminEmail% -f %VSSadminEmail% -a "VSS SCRIPT" -h -m %logfile%

) else (
time/t >> %logfile%
::NET send %VSSAdmin% "VSSMaint.cmd is Sussessful. log file : %LOGFILE%"
::NET send %VSSBackupAdmin% "VSSMaint.cmd is Sussessful. log file : %LOGFILE%"
if exist sendemails_on bmail -s %MailServer% -t %VSSadminEmail% -f %VSSadminEmail% -a "VSS SCRIPT" -h -m %logfile%

)

echo RE-SHARING VSS %sharename% >>%logfile%
call :reShareVSS
ECHO --------------- END OF LOG ENTRY -------------->>%logfile%
ECHO ===============================================>>%logfile%
ECHO .>>%logfile%
ECHO .>>%logfile%
goto :EOF

:HELP
ECHO Visual SourceSafe Maintenance Script
ECHO ====================================
ECHO VSSMAINT [/?] [COPY]
ECHO [-copy] copy of data tree to data.bak
ECHO [/?] HELP
ECHO .
ECHO Analyze puts its log info in databackupanalyze.log,which is also copied to
ECHO a log file generated by this script %LOGFILE%
ECHO For each analyze run, we preserve the existing databackup dir.
ECHO At the end of three runs:
ECHO databackup.0 is the original run,
ECHO databackup.1 is the next run, and
ECHO databackup is the most recent run.
ECHO data.bak is a copy of the data dir, prior to the original run.
ECHO data.bak0 is a copy of data.bak from the previous maintenance cycle.

 

:unShareVSS
call :mkSharecmd %sharename%
rmtshare %sharename% /delete
goto :EOF


:reShareVSS
call reshare.cmd

goto :EOF


:mkSharecmd
set sharecmd=rmtshare %1
:: get the local share directory
for /f "tokens=2" %%a in ('rmtshare %1^|findstr /b "Path"') do (
set sharecmd=%sharecmd%=%%a
)
:: now get the current share permissions
for /f "tokens=*" %%a in ('rmtshare %1^|findstr /b /c:" "') do (
for /f "tokens=1,3" %%b in ("%%a") do (
@call :exec set sharecmd=%%sharecmd%% /grant %%b:%%c
)
)
echo %sharecmd%>reShare.cmd
echo ------- %sharecmd%-------
goto :EOF

Last Updated on Friday, 13 November 2009 23:26