private async Task ExecuteBackup() { var backup = new BackupMysql(_backupConfigurations.ConnectionString); var folderPath = $"{Path.GetTempPath()}{DateTime.Now.ToString("yyyy_MM_dd_HH_mm_ss")}"; var backupFile = $"{folderPath}\\backup.sql"; Directory.CreateDirectory(folderPath); string ret = backup.BackupDatabase(backupFile); if (!string.IsNullOrWhiteSpace(ret)) { var ex = new BackupException(ret); _logger.LogError(ex, ret); throw ex; } var zipPath = folderPath + ".zip"; ZipFile.CreateFromDirectory(folderPath, zipPath); var googleDrive = new GoogleDrive(_logger, _configuration); await Task.Delay(1000); googleDrive.UploadZipedFile(zipPath); }
/// <summary> /// Prints an exit message in an error color and waits for ENTER before closing the program so that /// the window does not close immediately. /// </summary> public static void ExitAfterError(BackupException e) { // print error messages and (if given) error details foreach (string msg in e.ErrorMessages) { ConsoleWriter.WriteErrorMessage(msg); } if (e.ErrorDetails != null) { foreach (string details in e.ErrorDetails) { ConsoleWriter.WriteErrorDetails(details); } } // exit message with error color ConsoleWriter.WriteErrorMessage(Lang.EndProgram); // wait for input until actual closing Console.ReadLine(); Environment.Exit(0); }