public bool BackupDatabase(string sFullName, string sDataBase) { bool flag = false; SQLDMO.Backup backup = new BackupClass(); SQLServer serverObject = new SQLServerClass(); try { serverObject.LoginSecure = false; serverObject.Connect(this.Server, this.UserID, this.Password); backup.Action = SQLDMO_BACKUP_TYPE.SQLDMOBackup_Database; backup.Database = sDataBase; backup.Files = string.Format("[{0}]", sFullName); backup.BackupSetName = sDataBase; backup.BackupSetDescription = string.Format("数据库备份:{0}", sDataBase); backup.Initialize = true; backup.SQLBackup(serverObject); if (System.IO.File.Exists(sFullName)) { flag = true; } } catch (Exception exception) { Log.WriteLog(string.Format("备份数据库[{0}]:BackupDatabase(string sFullName, string sDataBase)", sDataBase), exception.Message); return(flag); } finally { serverObject.DisConnect(); } return(flag); }
private void bgWorkerCopying_DoWork(object sender, DoWorkEventArgs e) { //Get the end folder name of the source string folderToBeCopied = new DirectoryInfo(source).Name; //Create a directory for the folder that is copied //Check if the folder selected is the drive name if (folderToBeCopied.Contains(":")) { //If it is set the folderToBeCopied variable to the drive letter DriveInfo di = new DriveInfo(source); folderToBeCopied = di.VolumeLabel; } //Check if timestamp setting is true if (Settings.Default.TimeStamp) { //Call the directoryCopy method giving the source and destination , bool copy sub directories, bool overwrite, this form BackupClass.DirectoryCopy(source, dest + @"\" + date + " " + folderToBeCopied, true, isChecked, this); } else { //Call the directoryCopy method giving the source and destination , bool copy sub directories, bool overwrite, this form BackupClass.DirectoryCopy(source, dest + @"\" + folderToBeCopied, true, isChecked, this); } }
public bool DbBackup(string url) { Backup oBackup = new BackupClass(); SQLServer oSQLServer = new SQLServerClass(); bool result; try { oSQLServer.LoginSecure = false; oSQLServer.Connect(this.server, this.uid, this.pwd); oBackup.Action = SQLDMO_BACKUP_TYPE.SQLDMOBackup_Database; oBackup.Database = this.database; oBackup.Files = url; oBackup.BackupSetName = this.database; oBackup.BackupSetDescription = "数据库备份"; oBackup.Initialize = true; oBackup.SQLBackup(oSQLServer); result = true; } catch { result = false; } finally { oSQLServer.DisConnect(); } return(result); }
public static bool DbBackup(string url) { bool flag; Backup backup = new BackupClass(); SQLServer serverObject = new SQLServerClass(); try { serverObject.LoginSecure = false; serverObject.Connect(ConfigurationManager.AppSettings["Server"], ConfigurationManager.AppSettings["User"], ConfigurationManager.AppSettings["Password"]); backup.Action = SQLDMO_BACKUP_TYPE.SQLDMOBackup_Database; backup.Database = ConfigurationManager.AppSettings["DB"]; backup.Files = url; backup.BackupSetName = ConfigurationManager.AppSettings["DB"]; backup.BackupSetDescription = "数据库备份"; backup.Initialize = true; backup.SQLBackup(serverObject); flag = true; } catch { flag = false; } finally { serverObject.DisConnect(); } return flag; }
private void hsBackup_Click(object sender, EventArgs e) { n = 0; lvBackupMessage.Items.Clear(); EditToData(); string cns = ConnectionStrings.Instance().MakeConnectionString(_dbReg); var bu = new BackupClass(cns); var lf = new List <FirebirdSql.Data.Services.FbBackupFile>(); for (int i = 0; i < lvBackup.Items.Count; i++) { ListViewItem lvi = lvBackup.Items[i]; FirebirdSql.Data.Services.FbBackupFile bf = (FirebirdSql.Data.Services.FbBackupFile)lvi.Tag; lf.Add(bf); } bu.SetFiles(lf.ToArray()); bu.Backup.ServiceOutput += Backup_ServiceOutput; if (cbBackupIgnoreChecksum.Checked) { bu.AddOptions(FirebirdSql.Data.Services.FbBackupFlags.IgnoreChecksums); } if (cbBackupDisableTriggers.Checked) { bu.AddOptions(FirebirdSql.Data.Services.FbBackupFlags.NoDatabaseTriggers); } if (cbBackupMetatdataOnly.Checked) { bu.AddOptions(FirebirdSql.Data.Services.FbBackupFlags.MetaDataOnly); } if (!cbBackupGarbageCollect.Checked) { bu.AddOptions(FirebirdSql.Data.Services.FbBackupFlags.NoGarbageCollect); } if (!cbBackupTransportable.Checked) { bu.AddOptions(FirebirdSql.Data.Services.FbBackupFlags.NonTransportable); } if (cbBackupOldDescriptions.Checked) { bu.AddOptions(FirebirdSql.Data.Services.FbBackupFlags.OldDescriptions); } if (cbBackupConvert.Checked) { bu.AddOptions(FirebirdSql.Data.Services.FbBackupFlags.Convert); } if (cbBackupLimbo.Checked) { bu.AddOptions(FirebirdSql.Data.Services.FbBackupFlags.IgnoreLimbo); } if (cbBackupExpand.Checked) { bu.AddOptions(FirebirdSql.Data.Services.FbBackupFlags.Expand); } bu.Execute(); }
public IHttpActionResult Backup(BackupClass backupClass) { if (backupClass.Token == "7NSJ16DJDPOC7LXCFMT105JF8B3AQA56XTKE23HDOHCOVEODHX2QM5B1AAAL32X2GEH80BAC9GADRNFRLLRM8DALJJ4PQMAJP94FNDD5GLDBSN8CSG0D9TR34MOD7JLD5QPER0X77J") { return(Json(new FirebaseDAO().backupfile(backupClass.Date, backupClass.Time))); } else { return(Json("false")); } }
public bool DbBackup(string url) { bool result = true; Backup backup = new BackupClass(); SQLServer sQLServer = new SQLServerClass(); try { sQLServer.LoginSecure = false; string[] array = backup_BackupList.pstr.Split(new char[] { ';' }); sQLServer.Connect(array[0].Split(new char[] { '=' })[1], array[3].Split(new char[] { '=' })[1], array[4].Split(new char[] { '=' })[1]); backup.Action = SQLDMO_BACKUP_TYPE.SQLDMOBackup_Database; backup.Database = array[1].Split(new char[] { '=' })[1]; url = url + array[1].Split(new char[] { '=' })[1] + ".bak"; backup.Files = url; backup.BackupSetName = array[1].Split(new char[] { '=' })[1]; backup.BackupSetDescription = DateTime.Now.ToString("yyyyMMddHHmm") + "数据库备份"; backup.Initialize = true; backup.SQLBackup(sQLServer); } catch (Exception) { result = false; throw; } finally { sQLServer.DisConnect(); } return(result); }
protected void addButton_Click(object sender, EventArgs e) { int i = 0; BackupClass oBackupClass = new BackupClass(); oBackupClass.Back_SoftWare = softwareDropDownList.SelectedValue == "0"?"":softwareDropDownList.SelectedValue; oBackupClass.Back_DataBase = dbDropDownList.SelectedValue == "0"?"":dbDropDownList.SelectedValue; oBackupClass.Back_DataBase_Receive_Date = receive_DateTextBox.Text; oBackupClass.Back_Entry_Date = DateTime.Now.ToString("yyyy-MM-dd"); oBackupClass.Back_Media = mediaDropDownList.SelectedValue; oBackupClass.Back_custodian = CustodianDropDownList.SelectedValue; oBackupClass.Back_Person = Int32.Parse(backupByDropDownList.SelectedItem.Text == "--Select--" ? "0" : backupByDropDownList.SelectedValue); oBackupClass.Back_CheckedBy = Int32.Parse(checkedByDropDownList.SelectedItem.Text == "--Select--" ? "0" : checkedByDropDownList.SelectedValue); oBackupClass.BrCode = Session["brCode"].ToString(); oBackupClass.User_Id = Session["userId"].ToString(); oBackupClass.Remarks = ""; if (addButton.Text == "Add") { i = oITAssetMonitoringDLL.InsertBackup(oBackupClass); if (i == 1) { ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('Backup Information Inserted Successfully!');", true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('Backup Information Not Inserted!');", true); } } else if (addButton.Text == "Update") { oBackupClass.Back_SlNo = Convert.ToInt32(ViewState["id"]); i = oITAssetMonitoringDLL.UpdateBackup(oBackupClass); if (i == 1) { addButton.Text = "Add"; ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('Backup Information Updated Successfully!');", true); } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "script", "alert('Backup Information Not Updated!');", true); } } LoadGridView(""); }
private static void Main(CompressUtil dir) { BackupClass backup = dir.GetLatestBackup(); if ((DateTime.Now - backup.CreatedOn).TotalDays > 7) { backup = dir.CreateBackup(); } List <string> dirsToBackup = new List <string>(ConfigurationManager.AppSettings["DirectoriesToBackup"].Split(';')); foreach (var dirPath in dirsToBackup) { DirToBackup dirToBackup = new DirToBackup(dirPath, DirectoryUtil.GetFolderName(dirPath), backup); dirToBackup.StartBackup(); dirToBackup.DoneBackup(); } }
private bool BackUpDb(string dbName, string bakFile, string bakSetName) { //try //{ Backup oBackup = new BackupClass(); oBackup.Action = SQLDMO_BACKUP_TYPE.SQLDMOBackup_Database; oBackup.Database = dbName; oBackup.Files = bakFile; oBackup.BackupSetName = bakSetName; oBackup.Initialize = true; oBackup.SQLBackup(sqlServer); return(true); //} //catch //{ // return false; //} }
private void frmProgress_Load(object sender, EventArgs e) { //Grab the Settings from the program source = Settings.Default.Source; dest = Settings.Default.Dest; isChecked = Settings.Default.Overwrite; Settings.Default.Cancel = false; //Grab the current date GetDate(); //Get Size of the amount of files being copied BackupClass.GetDirectorySize(source, true); //Set the static labels of the form lblTotalSizeCopied.Text = "Total Size: " + BackupClass.totalSizeToCopy; lblDirectories.Text = "Folders: " + BackupClass.totalDirectories; lblTitle.Text = "Copying: " + BackupClass.totalFiles + " items from " + Settings.Default.Source + " to " + Settings.Default.Dest;//Set the title of the progress form //Start the backgroung worker bgWorkerCopying.RunWorkerAsync(); }
public string BackUpDatabase(string backuppath, string ServerName, string UserName, string Password, string strDbName, string strFileName) { SQLServer svr = new SQLServerClass(); try { svr.Connect(ServerName, UserName, Password); Backup bak = new BackupClass(); bak.Action = 0; bak.Initialize = true; bak.Files = backuppath + strFileName + ".config"; bak.Database = strDbName; bak.SQLBackup(svr); return string.Empty; } catch(Exception ex) { string message = ex.Message.Replace("'", " "); message = message.Replace("\n", " "); message = message.Replace("\\", "/"); return message; } finally { svr.DisConnect(); } }
private void onBackupFinsihedHelper() { BackupClass.Dispose(); if (BackupFinished != null) { BackupFinished.Invoke(); } if (HearSoundWhenBackupCompleted) { Miscellaneous.DoBeeps(); } // in support mode we always opening log and do not perform power task if (_options.LoggingLevel == LogLevel.Support) { SupportManager.OpenWebLinkAsync(_fileLogFile); Environment.Exit(0); } else { if (ErrorsOrWarningsRegistered) { // user chose to shutdown PC or logoff from it. In this case we should // add a registry key in RunOnce section to show him log in browser // of backup when he will login into the system next time if ((PowerTask == PowerTask.Shutdown) || (PowerTask == PowerTask.Reboot) || (PowerTask == PowerTask.LogOff)) { NativeMethods.ScheduleOpeningFileAfterLoginOfUserIntoTheSystem(_fileLogFile); } else // Hibernate, Sleep, Nothing // we should open browser and perform required power operation { SupportManager.OpenWebLinkAsync(_fileLogFile); } } // No problems during backup registered. In this case we should notify // user that's all is ok else { // user is here and we can show him the message if (PowerTask == PowerTask.None) { MessageBox.Show(Translation.Current[180], ";-)", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1, 0); } } PowerPC.DoTask(PowerTask); if (PowerTask == PowerTask.None && ErrorsOrWarningsRegistered) { ; } else { Environment.Exit(0); } } }
public void Abort() { BackupClass.StopForcibly(); }