Click or drag to resize

IInfrascaleSdkSetOnlineBackupSettings Method

Add Online Backup settings to the settings storage.

Namespace:  SOS.SDK.Contracts
Assembly:  SOS.SDK (in SOS.SDK.dll) Version: 7.6.1.5742
Syntax
C#
SetOnlineBackupSettingsResponse SetOnlineBackupSettings(
	SetOnlineBackupSettingsRequest request
)

Parameters

request
Type: SOS.SDK.Contracts.DataContracts.RequestsSetOnlineBackupSettingsRequest
Container with request parameters.

Return Value

Type: SetOnlineBackupSettingsResponse
Operation execution results.
Exceptions
ExceptionCondition
NotSignedIn
MethodCallFailed
Remarks
Use OnlineBackupSettingsContractCreator to simplify the process of creating backup settings.
Examples
Setting Online Backup settings using raw contracts
using System;
using System.Diagnostics;
using System.Security.Principal;
using SOS.SDK.Contracts.DataContracts;
using SOS.SDK.Contracts.DataContracts.Jobs;
using SOS.SDK.Contracts.DataContracts.Jobs.Backup;
using SOS.SDK.Contracts.DataContracts.Requests;
using SOS.SDK.Tools.Creators;
using SOS.SDK.Tools.Runners;

namespace SOS.SDK.Test.Examples.OnlineBackup
{
    public class RunOnlineBackupExamples
    {
        private string _testAccount = @"sdk.test@sosonlinebackup.com";
        private string _testAccountPassword = @"qweqwe";
        private InfrascaleClient _client;
        private IdentityContract _identity;

        public void SignIn()
        {
            if (_client == null)
            {
                _client = new InfrascaleClient();
                _client.Connect();
                _identity = null;
            }

            if (_identity == null)
            {
                var signInResponse = _client.SignIn(new SignInRequest
                {
                    Credentials = new CredentialsContract { Login = _testAccount, Password = _testAccountPassword }
                });

                _identity = signInResponse.Identity;

                _client.SubscribeCallback(new SubscribeCallbackRequest {Identity = _identity});
            }
        }

        public void SetOnlineBackupSettings()
        {
            SignIn();

            var fileSet = new FilesetContract
            {
                // This directories will be included to BackupSet (recursively)
                IncludedDirs = new[]
                {
                    new FilesetDirContract {DirectoryPath = @"C:\BackupRoot"},
                    // Even if your network share is mapped to drive letter, use real remote path of this directory
                    new FilesetDirContract {DirectoryPath = @"\\networkshare\share\NetworkBackupRoot"}
                },
                // This files will be included to BackupSet
                IncludedFiles = new[] { new FilesetFileContract { FilePath = @"C:\Backup.txt" } },
                // This items will be excluded from BackupSet.
                Excludes = new[]
                {
                    // This folder and all child items will be excluded
                    new FilesetExcludeItemContract {ExcludePath = @"C:\BackupRoot\DoNotBackup"},
                    // This file will be excluded
                    new FilesetExcludeItemContract {ExcludePath = @"C:\BackupRoot\DoNotBackup.txt"}
                }
            };

            var obSettings = new OnlineBackupSettingsContract
            {
                ProtectFileset = fileSet,
                // If you added network folders to the BackupSet - describe the settings for accessing network locations
                NetShares = new[]
                {
                    new NetShareContract
                    {
                        Credentials = new CredentialsContract {Login = "networkuser", Password = "password"},
                        RemoteName = @"\\networkshare\share\NetworkBackupRoot"
                    }
                }
            };

            var request = new SetOnlineBackupSettingsRequest { Identity = _identity, Settings = obSettings };

            // Infrascale stores this settings as online backup settings for an authenticated user
            _client.SetOnlineBackupSettings(request);

            SignOut();
        }
    }
}
Setting Online Backup settings using helper
using System;
using System.Diagnostics;
using System.Security.Principal;
using SOS.SDK.Contracts.DataContracts;
using SOS.SDK.Contracts.DataContracts.Jobs;
using SOS.SDK.Contracts.DataContracts.Jobs.Backup;
using SOS.SDK.Contracts.DataContracts.Requests;
using SOS.SDK.Tools.Creators;
using SOS.SDK.Tools.Runners;

namespace SOS.SDK.Test.Examples.OnlineBackup
{
    public class RunOnlineBackupExamples
    {
        private string _testAccount = @"sdk.test@sosonlinebackup.com";
        private string _testAccountPassword = @"qweqwe";
        private InfrascaleClient _client;
        private IdentityContract _identity;

        public void SignIn()
        {
            if (_client == null)
            {
                _client = new InfrascaleClient();
                _client.Connect();
                _identity = null;
            }

            if (_identity == null)
            {
                var signInResponse = _client.SignIn(new SignInRequest
                {
                    Credentials = new CredentialsContract { Login = _testAccount, Password = _testAccountPassword }
                });

                _identity = signInResponse.Identity;

                _client.SubscribeCallback(new SubscribeCallbackRequest {Identity = _identity});
            }
        }

        public void SetOnlineBackupSettingsWithCreator()
        {
            SignIn();

            var creator = new OnlineBackupSettingsContractCreator();
            creator.AddDir(@"C:\BackupRoot");
            creator.AddDir(@"\\networkshare\share\NetworkBackupRoot");
            creator.AddFile(@"C:\Backup.txt");
            creator.Exclude(@"C:\BackupRoot\DoNotBackup");
            creator.Exclude(@"C:\BackupRoot\DoNotBackup.txt");
            creator.AddNetworkShare(@"\\networkshare\share\NetworkBackupRoot", "networkuser", "password");

            var request = new SetOnlineBackupSettingsRequest { Identity = _identity, Settings = creator.Create() };

            // Infrascale stores this settings as online backup settings for an authenticated user
            _client.SetOnlineBackupSettings(request);

            SignOut();
        }
    }
}
See Also