Backup your Team Services Git Repositories with VSTS Vault

Backup your Team Services Git Repositories with VSTS Vault: A simple windows service or console application designed to keep a local copy of all your code.

Since January 2016 we’ve moved the source code of more than 30 projects to Git repositories hosted by Visual Studio Team Services.

Moving to the cloud has some downsides and one thing that kept us thinking was the need to be sure that in the event of an internet connection failure or a Team Services outage we would be able to access our code and deploy hot fixes for our applications as part of our data protection plan.

Surfing on the web I found this post: Free Visual studio online backup tool that talks about VSOBackup a free tool to create backups of your code by dates.

We needed a solution capable of minimizing the RPO (Recovery Point Objetive) and where the backups could be connected to an on-premises Git Server such as GitBlit.

Those are the main reason we could not use VSOBackup and why, inspired by such a great code base, I created a Windows service: VSTS.Vault with the capability of cloning your Git repositories and then pulling for changes every 5 minutes which is the default setting.

Vsts.Vault is a Windows Service and to use it you’ll need to follow these steps:

1. Create Alternate Credentials for your Visual Studio Team Services Account
2. Configure VSTS.Vault Settings
3. Install the VSTS.Vault service

If you look through the VSTS.Vault code base you’ll see some interesting features:

  1. Use of MEF as to implement dependency injection
  2. Use of LibGit2Sharp
  3. Use of Visual Studio Team Services REST API
  4. And the use of the Retry Pattern

To finish this post I have to say that We’ve been running the service now for more than a month and connected the resulting repository backups to GitBlit without issues.

Hope it helps…

7 thoughts on “Backup your Team Services Git Repositories with VSTS Vault

  1. Hey! I would like to use your tool to backup our repositories from vsts as well 🙂 When i try to install the service i get a System.InvalidOperationException, do you have an idea whats wrong? Thx a lot!

      1. Hi Carlos, thx for your quick reply! I have run the console application successfully before and copied the VaultConfiguration part into the service before trying to install the service.

        Here is my log file (Its german but it is saying that i couldnt install the service because the service didnt start in time):
        Assembly c:\VSTS.Vault\Vsts.Vault.exe wird installiert.
        Betroffene Parameter:
        logtoconsole =
        logfile = c:\VSTS.Vault\Vsts.Vault.InstallLog
        assemblypath = c:\VSTS.Vault\Vsts.Vault.exe
        Dienst Vsts.Vault wird installiert…
        Dienst Vsts.Vault wurde installiert.
        Die EventLog-Quelle Vsts.Vault im Protokoll Application wird erstellt…
        Im Ereignishandler OnAfterInstall von Vsts.Vault.WindowsService.Installer ist eine Ausnahme aufgetreten.
        System.InvalidOperationException: Der Dienst Vsts.Vault kann nicht auf dem Computer . gestartet werden.
        Die interne Ausnahme System.ComponentModel.Win32Exception wurde mit folgender Fehlermeldung ausgelöst: Der Dienst antwortete nicht rechtzeitig auf die Start- oder Steuerungsanforderung.
        Assembly c:\VSTS.Vault\Vsts.Vault.exe wird zurückgesetzt.
        Betroffene Parameter:
        logtoconsole =
        logfile = c:\VSTS.Vault\Vsts.Vault.InstallLog
        assemblypath = c:\VSTS.Vault\Vsts.Vault.exe
        Der vorherige Zustand des Ereignisprotokolls für die Quelle Vsts.Vault wird wiederhergestellt.
        Der Dienst Vsts.Vault wird vom System entfernt…
        Dienst Vsts.Vault wurde vom System entfernt.

        1. I found an english server and created the error output there 😉

          Running a transacted installation.

          Beginning the Install phase of the installation.
          See the contents of the log file for the c:\VSTS.Vault\Vsts.Vault.exe assembly’s progress.
          The file is located at c:\VSTS.Vault\Vsts.Vault.InstallLog.
          Installing assembly ‘c:\VSTS.Vault\Vsts.Vault.exe’.
          Affected parameters are:
          logtoconsole =
          logfile = c:\VSTS.Vault\Vsts.Vault.InstallLog
          assemblypath = c:\VSTS.Vault\Vsts.Vault.exe
          Installing service Vsts.Vault…
          Service Vsts.Vault has been successfully installed.
          Creating EventLog source Vsts.Vault in log Application…
          An exception occurred in the OnAfterInstall event handler of Vsts.Vault.WindowsService.Installer.
          System.InvalidOperationException: Cannot start service Vsts.Vault on computer ‘.’.
          The inner exception System.ComponentModel.Win32Exception was thrown with the following error message: The service did not respond to the start or control request in a timely fashion.

          An exception occurred during the Install phase.
          System.InvalidOperationException: An exception occurred in the OnAfterInstall event handler of Vsts.Vault.WindowsService.Installer.
          The inner exception System.InvalidOperationException was thrown with the following error message: Cannot start service Vsts.Vault on computer ‘.’..
          The inner exception System.ComponentModel.Win32Exception was thrown with the following error message: The service did not respond to the start or control request in a timely fashion.

          The Rollback phase of the installation is beginning.
          See the contents of the log file for the c:\VSTS.Vault\Vsts.Vault.exe assembly’s progress.
          The file is located at c:\VSTS.Vault\Vsts.Vault.InstallLog.
          Rolling back assembly ‘c:\VSTS.Vault\Vsts.Vault.exe’.
          Affected parameters are:
          logtoconsole =
          logfile = c:\VSTS.Vault\Vsts.Vault.InstallLog
          assemblypath = c:\VSTS.Vault\Vsts.Vault.exe
          Restoring event log to previous state for source Vsts.Vault.
          Service Vsts.Vault is being removed from the system…
          Service Vsts.Vault was successfully removed from the system.

          The Rollback phase completed successfully.

          The transacted install has completed.
          The installation failed, and the rollback has been performed.

Leave a Reply

Your email address will not be published. Required fields are marked *