/SnapRepo

Snapshot Backup Azure Repository

Primary LanguageC#

SnapRepo - Snapshot Backup Azure Repository

Single click and scheduled backups/restores for SQL Server DB and AppData files.

SnapRepo is for automating backups and restores

SnapRepo is mainly targeted for handling and automating backups and restoring data of web site projects (like Episerver CMS). It's backing up data to Azure Blob storage from virtual machines or local server and restoring it vice versa. Backup data includes SQL Server Database and AppData folders.


Snaprepo website can be installed in the same server (with target website) or another server in same network.

SnapRepo is designed for following use cases and purposes

  • Managing backup archives
    • List, Create, Delete, Download and Upload backups
  • Monitoring backups
  • Scheduling daily, weekly and monthly backups
  • Scheduling cleaning of old backups
  • Transferring data between environments (Production, Staging, Testing, Dev, Local)
  • Helping integration testing (or any other kind of processes which needs the environment to be restored several times)
    • Quickly create/restore snapshots of data so it would be easy to rerun the process.
    • You may even have different snapshots for different test scenarios.
  • Backups before production deployments or even automate the backups in deployments
  • Works on my machine -problems and easing the problem solving of production environment
  • Improving the data integrity by handling full backup packages. Packages are meant to create and restored with the same application.

Usage

HTML-demo of the application. It contains only visual side of the application.

Installation

 

This instruction is to install the SnapRepo as parallel to target web site. SnapRepo needs to exists in same server or at least in same network to access the data.

  1. Create IIS site from the deployment package zip-file or from the GitHub repository sources
  2. Enable IIS Basic Authentication or implement your own authentication.
  3. Create Azure Blob Storage (type: private)
  4. Set up 2 connection strings:
    1. AzureBackupBlobStorage
      Connections string to Azure Blob Storage. Read more
      Example: <add name="AzureBackupBlobStorage" connectionString="DefaultEndpointsProtocol=[http|https];AccountName=accountName;AccountKey=accountKey" />
    2. SnapRepo
      Connection string to SQL Server (with high user privileges)
      Example: <add name="SnapRepo" connectionString="Data Source=(local);Initial Catalog=DatabaseName;User ID=sa;Password=sa_password;Connection Timeout=1800;Integrated Security=False;MultipleActiveResultSets=True" providerName="System.Data.SqlClient" />
  5. Make sure that following settings are correct
    • Make sure your IIS application user has access to required resources (folders) and SQL Server user (in connection string) has necessary privileges.
    • SnapRepo needs to have long timeouts for requests and db connections. By default this site has 60min (3600secs) timeouts and SQL Connection timeout is set to 30 minutes (1800secs).
    • Scheduled services required that the IIS site needs to be alive all the time. So you need to set:
      1. application pool Start Mode = "AlwaysRunning"
      2. from IIS site Advance Settings Preload Enabled = True
      3. or some sort of scheduled pinger (Example uptimerobot.com)
  6. Start using it!

Configuration options

 

From web.config <appSettings> you can change the default configuration of following settings:

  • Local repository path:
    <add key="SnapRepo.LocalRepositoryPath" value="C:\Sites\ExampleSite\SnapRepository\"/>
  • AppData folder path:
    <add key="SnapRepo.AppDataFolder" value="C:\Sites\ExampleSite\AppData" />
  • IIS site name:
    <add key="SnapRepo.IisSiteName" value="ExampleSite" />
  • Blob storage container name:
    <add key="SnapRepo.ContainerName" value="CustomBlobStorageContainerName"/>
  • Database shared folder path (for transferring database backup):
    <add key="SnapRepo.DbSharedBackupFolder" value="\\ServerName\Shared\Folder\"/>
  • Disable basic authentication:
    <add key="SnapRepo.UseBasicAuth" value="False" />
  • Protect the site with IP-restrictions:
    <add key="SnapRepo.AllowedIpAddresses" value="127.0.0.1, 8.8.8.8, 8.8.4.4" />
  • Disable user group checks:
    <add key="SnapRepo.CheckUserGroups" value="False"/>
  • Disable HTTPS-redirect:
    <add key="SnapRepo.ForceHttps" value="False"/>
  • Disable usage of Zip64 (disables large backups):
    <add key="SnapRepo.UseZip64WhenSaving" value="False"/>

Same settings are in application:


Requirements and Nugets

 

Build with .NET Framework 4.6.1.

Depends on 4 NuGet Packages

  1. WindowsAzure.Storage version="7.2.1"
  2. DotNetZip version="1.9.1.8"
  3. FluentScheduler version="5.0.0"
  4. Microsoft.Web.Administration version="7.0.0.0"

Access rights

 

You may use SnapRepo without restore function so then read access to the db and appdata folder is sufficient.

Restorind data requires a lot more priviledges:

  • IIS application pool user needs to have write and delete access to Local Repository -folder and AppData-folder.
  • SQL Server user needs to have sysadmin (create, restore and query databases) privileges in SQL Server

Security and usage

 

By default this application uses basic authentication and check's that user belongs to one of this groups: WebAdmins, CmsAdmins, Administrators. But you can easily change authentication and use your own.

With basic authentication it's recommended to use secured connection with HTTPS-protocol.

It's also recommended to use IP-restrictions to restrain access from your network with IIS or implement it with URLRewrite module.