How to automatically backup SourceSafe? (2005-04-27)

For our source code's security, an adminstrator of Microsoft Visual SourceSafe should do a backup daily, or weekly at least. The backup process won't cost us a long time, but we prefer automatical backup for sure. Let me introduce how to implement a daily backup by making use of existing tools. Of course, by making a slight change, you can get a weekly, monthly, or even yearly solution.

Tools Required

  • ssarc.exe. ssarc.exe is a backup tool offered by SoureSafe. It's in "win32" directory which is under the installation path of SouceSafe.
  • schtasks. In Windows Server 2003, schtasks allows an administrator creating, deleting, querying, configurng, running and stopping local or remote scheduled tasks in system. It is designed to replace al.exe.

Steps

  • Create a batch file names as "backup.bat" in "c:\backup\bin" directory;
  • Write the following commands into the file:
    • @echo off
    • @title Backing up SourceSafe databases
    •  
    • set SsPath=C:\Program Files\Microsoft Visual Studio\VSS\win32\
    • set BakPath=C:\backup\content\
    •  
    • "%SsPath%ssarc.exe" -d- -s"Path to a SourceSafe Database" -i- -yadmin,password -o@"%BakPath%Backup-output(%DATE%).txt" "%BakPath%Backup-Database(%DATE%).ssa" $/
    •  
    • echo Finished backups
    • @echo on
    If the sourcesafe database is not at your local computer, you should use the "NET USE" command first:
    • @echo off
    • @title Backing up SourceSafe databases
    •  
    • NET USE \\vss_server\vss_share password /USER:domainname\username /PERSISTENT:yes
    • set SsPath=C:\Program Files\Microsoft Visual Studio\VSS\win32\
    • set BakPath=C:\backup\content\
    • ....

    Note:

    • SsPath: the path to the "win32" directory.
    • BakPath: the path where backup files are saved.
    • You should replace "Path to a SourceSafe Database" as the path to the "SrcSafe.ini" file of a SourceSafe database.
    • Please replace "Password" as the administrator's password.
    • After a backup process, there will be two generated files under "c:\backup\content", and they are "Backup-output(2004-11-01).txt" (the output file), "Backup-Database(2004-11-01).ssa" (the backup file). 2004-11-01 is the date when the backup operation is carrying out.

  • Use schtasks to create a scheduled task.
    schtasks /create /RU system /SC DAILY /ST 12:00 /TN "SourceSafe Backup" /TR "cmd /c C:\backup\bin\backup.bat"

    Note:

    • /RU system, run the command under "NT AUTHORITY\SYSTEM" account.
    • /SC DAILY, run the command one time a day. Valid values are MINUTE, HOURLY, DAILY, WEEKLY, MONTHLY, ONCE, ONSTART, ONLOGON, ONIDLE.
    • /ST 12:00 specifies the program will be started at 12:00.
    • /TN "SourceSafe Backup" specifies the name of the scheduled task.
    • /TR "cmd /c c:\backup\bin\backup.bat" specifies the program to be executed.

  • Congratulations, you have successfully created a scheduled task to implement the daily backup process. When type "schtasks" at command line, you can find "SourceSafe Backup" in the column called "Task Name".

References