Exemplo n.º 1
0
        protected override void Execute(CodeActivityContext context)
        {
            string serverName        = ServerName.Get(context);
            string databaseName      = DatabaseName.Get(context);
            string backupFilePath    = BackupFilePath.Get(context);
            string configurationFile = ConfigurationFile.Get(context);

            if (string.IsNullOrEmpty(serverName))
            {
                var serverConfig = Helper.GetServerConfig(configurationFile);
                serverName = serverConfig.DatabaseServer;
            }

            context.TrackBuildMessage(String.Format("Restoring database {0} on server {1} from file {2}", databaseName, serverName, backupFilePath));

            Sql.DbManagement.RestoreDbFromFile(serverName, databaseName, backupFilePath);

            context.TrackBuildMessage("Database restore complete");
        }
Exemplo n.º 2
0
        protected override void Execute(CodeActivityContext context)
        {
            string serverName          = ServerName.Get(context);
            string databaseName        = DatabaseName.Get(context);
            string backupFilePath      = BackupFilePath.Get(context);
            bool   overwriteBackupSets = OverwriteBackupSets.Get(context);
            bool   forceCompressionOn  = ForceCompressionOn.Get(context);
            string configurationFile   = ConfigurationFile.Get(context);

            if (string.IsNullOrEmpty(serverName))
            {
                var serverConfig = Helper.GetServerConfig(configurationFile);
                serverName = serverConfig.DatabaseServer;
            }

            context.TrackBuildMessage(String.Format("Backing up database {0} from server {1} to file {2}", databaseName, serverName, backupFilePath));

            Sql.DbManagement.BackupDbToFile(serverName, databaseName, backupFilePath, true, overwriteBackupSets, forceCompressionOn);

            context.TrackBuildMessage("Database backup complete");
        }