Setting up Backup

The simplest scenario would be to use provided service build around the messaging and scheduling framework. The example bellow assumes that there are partial backups each weekdays from Monday to Saturday and a full backup on each Sunday.
  • Configure backup configuration in the configuration file of each role which will host the backup message handlers, the example below assumes that you are configuring the messaging framework using the configuration file, you can control the degree of parallelism by which will affect the number of messages sent and maxDegreeOfParallelism which will affect number of threads to be used to process single message (bear in mind that considering latencies in Azure environment you can have quite high number of concurrent threads before you will max your CPU)
  <configSections>
    <section name="docaBusService" type="DocaAzure.Messaging.Config.BusServiceConfiguration, DocaAzure.Messaging" />
    <section name="tableDailyRollingBackup" type="DocaAzure.Backup.Service.Tables.Config.BackupTableConfiguration, DocaAzure.Backup" />
    <section name="tableWeeklyBackup" type="DocaAzure.Backup.Service.Tables.Config.BackupTableConfiguration, DocaAzure.Backup" />
    <section name="blobDailyRollingBackup" type="DocaAzure.Backup.Service.Blobs.Config.BackupBlobConfiguration, DocaAzure.Backup" />
    <section name="blobWeeklyBackup" type="DocaAzure.Backup.Service.Blobs.Config.BackupBlobConfiguration, DocaAzure.Backup" />
  </configSections>

  <docaBusService>
    <queues>
      <clear/>

      <add queueName="backuptables" maxDequeueCount="2" concurrentProcessingThrottle="2" errorQueueName="error" purgeOnStartup="false">
        <regularQueueSchedule initialPollInterval="60000" pollIntervalIncrement="10000" maximumWaitTimeWhenIdle="120000"/>
        <azureQueueTransport messageInvisibleTime="02:00:00"/>
      </add>

      <add queueName="backupblobs" maxDequeueCount="2" concurrentProcessingThrottle="2" errorQueueName="error" purgeOnStartup="false">
        <regularQueueSchedule initialPollInterval="60000" pollIntervalIncrement="10000" maximumWaitTimeWhenIdle="120000"/>
        <azureQueueTransport messageInvisibleTime="02:00:00"/>
      </add>

    </queues>
  </docaBusService>

  <tableDailyRollingBackup backupType="RollingWeekDay">
    <tables>
      <clear/>
      <add table="Products" ranges="@32" jobsPerTable="4" maxDegreeOfParallelism="1"/>
      <add table="ProductCategories" ranges="@32" jobsPerTable="4" maxDegreeOfParallelism="1"/>
      <add table="Customers" ranges="@32" jobsPerTable="4" maxDegreeOfParallelism="1"/>
      <add table="Membership" ranges="@32" jobsPerTable="4" maxDegreeOfParallelism="1"/>
    </tables>
  </tableDailyRollingBackup>

  <tableWeeklyBackup backupType="Daily">
    <tables>
      <clear/>
      <add table="Products" ranges="@32" jobsPerTable="4" maxDegreeOfParallelism="1"/>
      <add table="ProductCategories" ranges="@32" jobsPerTable="4" maxDegreeOfParallelism="1"/>
      <add table="Customers" ranges="@32" jobsPerTable="4" maxDegreeOfParallelism="1"/>
      <add table="Audit" ranges="@32" jobsPerTable="4" maxDegreeOfParallelism="1"/>
      <add table="Membership" ranges="@32" jobsPerTable="4" maxDegreeOfParallelism="1"/>
    </tables>
  </tableWeeklyBackup>

  <blobDailyRollingBackup backupType="RollingWeekDay">
    <blobs>
      <clear/>
      <add containerPrefix="data-of-" maxDegreeOfParallelism="4"/>
      <add containerPrefix="emails-of-" maxDegreeOfParallelism="4"/>
    </blobs>
  </blobDailyRollingBackup>

  <blobWeeklyBackup backupType="Daily">
    <blobs>
      <clear/>
      <add containerPrefix="data-of-" maxDegreeOfParallelism="4"/>
      <add containerPrefix="emails-of-" maxDegreeOfParallelism="4"/>
    </blobs>
  </blobWeeklyBackup>

  <appSettings>
    <add key="ExactScheduleBase.DefaultTimeZone" value="GMT Standard Time"/>
  </appSettings>
  • Configure and start the messaging service on Startup of your roles
            // configure bus service
            BusService.Service
                .ConfigureQueuesFromFile()
                .RegisterHandlers(typeof (BackupHandlersAssemblyMarker).Assembly);

            // start bus service
            BusService.Service.Start();
            Log.Info("Bus Service has started.");
  • Configure and start scheduler service, for convenience the service expects local times so if you won't ExactScheduleBase.DefaultTimeZone your service will most likely will be using some timezone in the US
            ExactScheduleBase.DefaultTimeZone =
                TimeZoneInfo.FindSystemTimeZoneById(DefaultConfigurationManager.Default.GetAppSetting("ExactScheduleBase.DefaultTimeZone"));

            // configure & start scheduler
            SchedulerService = new SchedulerService();
            AddBackupSchedules(SchedulerService);

            SchedulerService.Start();

        private static void AddBackupSchedules(SchedulerService service)
        {
            service.AddTrigger(new ScheduledActionTrigger("daily table backup",
                    () =>
                    DefaultTypeProvider.Default.Resolve<IBus>().Send(new TableBackupTriggerMessage
                    {
                        BackupConfiguration = "tableDailyRollingBackup",
                        OnlyIfModifiedSince = DateTime.UtcNow.AddDays(-1)
                    }))
            {
                Schedule = new DailySchedule
                {
                    Interval = 1,
                    Base = 1,
                    Guard = 5,
                    WeekDaysToSkip = WeekDaysToSkip.SkipSunday
                }
            });

            service.AddTrigger(new ScheduledActionTrigger("weekly table backup",
                    () =>
                    DefaultTypeProvider.Default.Resolve<IBus>().Send(new TableBackupTriggerMessage
                    {
                        BackupConfiguration = "tableWeeklyBackup"
                    }))
            {
                Schedule = new DailySchedule
                {
                    Interval = 1,
                    Base = 1,
                    Guard = 5,
                    WeekDaysToSkip = WeekDaysToSkip.SkipMonday | WeekDaysToSkip.SkipTuesday | WeekDaysToSkip.SkipWednesday | WeekDaysToSkip.SkipThursday | WeekDaysToSkip.SkipFriday | WeekDaysToSkip.SkipSaturday
                }
            });

            service.AddTrigger(new ScheduledActionTrigger("daily blob backup",
                    () =>
                    DefaultTypeProvider.Default.Resolve<IBus>().Send(new BlobContainerBackupTriggerMessage
                    {
                        BackupConfiguration = "blobDailyRollingBackup",
                        OnlyIfModifiedSince = DateTime.UtcNow.AddDays(-1)
                    }))
            {
                Schedule = new DailySchedule
                {
                    Interval = 1,
                    Base = 1,
                    Guard = 5,
                    WeekDaysToSkip = WeekDaysToSkip.SkipSunday
                }
            });

            service.AddTrigger(new ScheduledActionTrigger("weekly blob backup",
                    () =>
                    DefaultTypeProvider.Default.Resolve<IBus>().Send(new BlobContainerBackupTriggerMessage
                    {
                        BackupConfiguration = "blobWeeklyBackup"
                    }))
            {
                Schedule = new DailySchedule
                {
                    Interval = 1,
                    Base = 1,
                    Guard = 5,
                    WeekDaysToSkip = WeekDaysToSkip.SkipMonday | WeekDaysToSkip.SkipTuesday | WeekDaysToSkip.SkipWednesday | WeekDaysToSkip.SkipThursday | WeekDaysToSkip.SkipFriday | WeekDaysToSkip.SkipSaturday
                }
            });
        }
  • You can also trigger configured backups using DocaAzure.Backup.Cmdlets

Last edited Jun 8, 2011 at 9:57 PM by alexeikadyrov, version 7

Comments

No comments yet.