Beispiel #1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="config"></param>
 /// <param name="jobID"></param>
 /// <param name="target"></param>
 /// <returns></returns>
 public string Execute(string config, int jobID, IBackupTarget target)
 {
     using (BackupRunner br = new BackupRunner(FileBackupConfig.Load(config), jobID, target)) {
         int count = br.Run();
         return("{0} files was backed up".FillBlanks(count));
     }
 }
Beispiel #2
0
 /// <summary>
 /// Initializes a new instance of the <b>BackupRunner</b> class.
 /// </summary>
 /// <param name="config"></param>
 /// <param name="jobID"></param>
 /// <param name="target"></param>
 public BackupRunner(FileBackupConfig config, int jobID, IBackupTarget target)
 {
     this.config   = config;
     dbFile        = new FileInfo("{0}\\FileBackupDatabases\\{1}.s3db".FillBlanks(Configuration.DataDirectory.FullName, jobID));
     backupDirPath = new DirectoryInfo(config.Directory).FullName + "\\";
     this.target   = target;
 }
Beispiel #3
0
 public string Execute( string config, int jobID, IBackupTarget target )
 {
     //bool t = true;
     //while( t ) {
     //    System.Threading.Thread.Sleep( 200 );
     //}
     return "NullSchedule {0} executed".FillBlanks( jobID );
 }
Beispiel #4
0
 public string Execute(string config, int jobID, IBackupTarget target)
 {
     //bool t = true;
     //while( t ) {
     //    System.Threading.Thread.Sleep( 200 );
     //}
     return("NullSchedule {0} executed".FillBlanks(jobID));
 }
Beispiel #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="config"></param>
        /// <param name="jobID"></param>
        /// <param name="target"></param>
        /// <returns></returns>
        public string Execute(string config, int jobID, IBackupTarget target)
        {
            MSSQLDatabaseBackupConfig conf      = MSSQLDatabaseBackupConfig.Load(config);
            List <string>             databases = conf.Databases;

            if (databases == null || databases.Count == 0)
            {
                databases = new List <string>();
                List <string> tmp = MSSQLDatabaseBackupConfigGUI.GetDatabases(conf.Server, conf.Username, conf.Password);
                foreach (string s in tmp)
                {
                    if (!s.EqualsAny(StringComparison.OrdinalIgnoreCase, "master", "model", "msdb", "tempdb"))
                    {
                        databases.Add(s);
                    }
                }
            }
            bool   remoteCleanupOK = true;
            string outputDir       = conf.LocalTempDirectory;
            string remoteDir       = conf.RemoteTempDir;

            if (conf.IsLocalServer)
            {
                remoteDir = outputDir;
                outputDir = null;
            }
            foreach (string db in databases)
            {
                BackupResult res;
                using (SQLLocalBackup lb = new SQLLocalBackup(conf.Server, conf.Username, conf.Password, db)) {
                    res = lb.DoLocalBackup(remoteDir, outputDir, conf.AddDateToFilename);
                    if (!res.CleanupOK)
                    {
                        remoteCleanupOK = false;
                    }
                }
                if (conf.CompressFiles)
                {
                    res.OutputFilename = ZipFile(res.OutputFilename);
                }
                target.Store(new FileInfo(res.OutputFilename), "");
                //if( conf.SaveAs == SaveAsTypes.FTP ) {
                //    FTPFile( res.OutputFilename, conf );
                //    try {
                //        File.Delete( res.OutputFilename );
                //    } catch {
                //    }
                //}
            }
            if (!remoteCleanupOK)
            {
                return(@"{0} was backed up.
Temporary files on the remote server was not deleted.
Enable procedure xp_cmdshell to perform this".FillBlanks(databases.ToString(", ")));
            }
            return("{0} was backuped.".FillBlanks(databases.ToString(", ")));
        }
Beispiel #6
0
        private void cbTargetType_SelectedIndexChanged(object sender, EventArgs e)
        {
            TargetWrapper tw = cbTargetType.SelectedItem as TargetWrapper;

            pnlTargetConfig.Controls.Clear();
            if (tw == null || tw.job == null)
            {
                return;
            }
            Job.TargetType           = tw.job.GetType().FullName;
            tbTargetDescription.Text = tw.job.Description;
            target = tw.job;
            target.InitiateConfiguration(pnlTargetConfig, Job.TargetConfiguration);
        }
Beispiel #7
0
        /// <summary>
        /// This method is called when the ScheduleForm's Load event has been fired.
        /// </summary>
        /// <param name="sender">The <see cref="object"/> that fired the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> of the event.</param>
        private void ScheduleForm_Load(object sender, EventArgs e)
        {
            tbName.Text = Job.Name;
            try {
                AdvancedCRONControl cc = new AdvancedCRONControl(Job.CronConfig);
                cronControl = cc;
                pnlCron.Controls.Add(cc);
            } catch {
                SimpleCRONControl cc = new SimpleCRONControl();
                cronControl = cc;
                pnlCron.Controls.Add(cc);
            }
            cbScheduleType.SelectedIndex  = cronControl is AdvancedCRONControl ? 0 : 1;
            cronControl.SelectionChanged += cronControl_SelectionChanged;
            int ind = -1;

            for (int i = 0; i < Configuration.JobPlugins.Count; i++)
            {
                IBackupSchedule plug = Configuration.JobPlugins[i];
                cbJobType.Items.Add(new PlugWrapper(plug));
                if (string.Equals(Job.JobType, plug.GetType().FullName))
                {
                    ind = i;
                }
            }
            if (ind > -1)
            {
                cbJobType.SelectedIndex = ind;
                if (Job.ID > 0)
                {
                    cbJobType.Enabled = false;
                }
            }
            lvPreCommands.ListViewItemSorter = new ListViewItemComparer();
            List <CommandWrapper> commands = CommandWrapper.Parse(Job.PreCommands);

            if (commands.Count > 0)
            {
                int index = 0;
                foreach (CommandWrapper cw in commands)
                {
                    ListViewItem li = lvPreCommands.Items.Add(cw.Command);
                    li.Tag = index++;
                    li.SubItems.Add(cw.Arguments);
                }
                FixLVSize(lvPreCommands);
            }
            lvPostCommands.ListViewItemSorter = new ListViewItemComparer();
            commands = CommandWrapper.Parse(Job.PostCommands);
            if (commands.Count > 0)
            {
                int index = 0;
                foreach (CommandWrapper cw in commands)
                {
                    ListViewItem li = lvPostCommands.Items.Add(cw.Command);
                    li.Tag = index++;
                    li.SubItems.Add(cw.Arguments);
                }
                FixLVSize(lvPostCommands);
            }
            ind = -1;
            for (int i = 0; i < Configuration.TargetPlugins.Count; i++)
            {
                IBackupTarget tt = Configuration.TargetPlugins[i];
                cbTargetType.Items.Add(new TargetWrapper(tt));
                if (string.Equals(tt.GetType().FullName, Job.TargetType))
                {
                    ind = i;
                }
            }
            if (ind > -1)
            {
                cbTargetType.SelectedIndex = ind;
            }
            UpdateNext();
            isLoaded = true;
        }
Beispiel #8
0
 public TargetWrapper(IBackupTarget job)
 {
     this.job = job;
 }