//----------------------------------------------------------------------------- // backup //----------------------------------------------------------------------------- /// <summary> /// Performs the backup operation. The <paramref name="sBackupPath"/> and /// <paramref name="backupClient"/> parameters are mutually exclusive. If /// backupClient is null, then the backup will be created on disk in the /// location specified by sBackupPath. If backupClient is non-null, the /// sBackupPath parameter is ignored. /// </summary> /// <param name="sBackupPath"> /// The full pathname where the backup set is to be created. This parameter /// is ignored if the backupClient parameter is non-null. /// </param> /// <param name="sPassword"> /// Password to be used for the backup. A non-empty password allows the backup /// to be restored on a machine other than the one where the database exists. The /// database's encryption key (if encryption is enabled) will be wrapped in the /// specified password so that the backup can be restored to a different machine. /// </param> /// <param name="backupClient"> /// If non-null, the backupClient is an object the provides interfaces for storing /// backup data to disk, tape, or other media. If null, the backup data is stored /// to a file set specified by the sBackupPath parameter. /// </param> /// <param name="backupStatus"> /// If non-null, the backupStatus object provides an interface that this method /// calls to report backup progress. /// </param> /// <returns> /// Returns a sequence number for this backup. This is for informational /// purposes only. For instance, users can use it to label their backup tapes. /// </returns> public uint backup( string sBackupPath, string sPassword, BackupClient backupClient, BackupStatus backupStatus) { RCODE rc; uint uiSeqNum; BackupClientDelegate backupClientDelegate = null; BackupClientCallback fnBackupClient = null; BackupStatusDelegate backupStatusDelegate = null; BackupStatusCallback fnBackupStatus = null; if (backupClient != null) { backupClientDelegate = new BackupClientDelegate(backupClient); fnBackupClient = new BackupClientCallback(backupClientDelegate.funcBackupClient); } if (backupStatus != null) { backupStatusDelegate = new BackupStatusDelegate(backupStatus); fnBackupStatus = new BackupStatusCallback(backupStatusDelegate.funcBackupStatus); } if ((rc = xflaim_Backup_backup(m_pBackup, sBackupPath, sPassword, out uiSeqNum, fnBackupClient, fnBackupStatus)) != 0) { throw new XFlaimException(rc); } return(uiSeqNum); }
/// <summary> /// Instantiates a new instance. /// </summary> /// <param name="apiKey">The API key to use to communicate with the Vultr /// API.</param> /// <param name="apiURL">The optional Vultr API URL to use. Set this if you want /// to override the default endpoint (e.g. for testing).</param> /// <exception cref="ArgumentNullException">If <paramref name="apiKey"/> is null /// or empty.</exception> public VultrClient(string apiKey, string apiURL = VultrApiURL) { if (string.IsNullOrEmpty(apiKey)) { throw new ArgumentNullException("apiKey", "apiKey must not be null"); } Account = new AccountClient(apiKey, apiURL); Application = new ApplicationClient(apiKey, apiURL); Auth = new AuthClient(apiKey, apiURL); Backup = new BackupClient(apiKey, apiURL); Block = new BlockClient(apiKey, apiURL); DNS = new DNSClient(apiKey, apiURL); Firewall = new FirewallClient(apiKey, apiURL); ISOImage = new ISOImageClient(apiKey, apiURL); Network = new NetworkClient(apiKey, apiURL); OperatingSystem = new OperatingSystemClient(apiKey, apiURL); Plan = new PlanClient(apiKey, apiURL); Region = new RegionClient(apiKey, apiURL); ReservedIP = new ReservedIPClient(apiKey, apiURL); Server = new ServerClient(apiKey, apiURL); Snapshot = new SnapshotClient(apiKey, apiURL); SSHKey = new SSHKeyClient(apiKey, apiURL); StartupScript = new StartupScriptClient(apiKey, apiURL); User = new UserClient(apiKey, apiURL); }
private static async Task MainAsync(string[] args) { var options = new CommandLineOptions(); // Parse in 'strict mode'; i.e. success or quit if (Parser.Default.ParseArgumentsStrict(args, options)) { try { Log.Debug("Results of parsing command line arguments: {@options}", options); var credentials = new NetworkCredential() { UserName = options.Username, Password = options.Password }; var backupClient = new BackupClient(new Uri(options.Url), credentials); logger.Information("Started backup."); await backupClient.AuthenticateAsync(); await backupClient.RequestJiraBackupAsync(); await backupClient.RequestConfluenceBackupAsync(); logger.Information("Sleeping for {seconds} seconds before starting download(s).", options.Sleep); Thread.Sleep(options.Sleep * 1000); await backupClient.DownloadJiraBackupAsync(new Uri(options.DestinationPath), DateTime.Now); await backupClient.DownloadConfluenceBackupAsync(new Uri(options.DestinationPath), DateTime.Now); logger.Information("Finished backup."); Environment.Exit((int)ExitCode.Success); } catch (Exception ex) { Log.Fatal("A fatal error occurred: {ex}", ex); } } Environment.Exit((int)ExitCode.Error); }
public async Task BackupComplete(Guid id) { try { await BackupClient.BackupCompleteAsync(id); } catch (EndpointNotFoundException) { throw new AgentNotFoundException(); } catch (SecurityNegotiationException) { throw new BadCredentialsException(); } catch (CommunicationObjectFaultedException) { throw new CommunicationFaultedException(); } }
private void StartButton_Click(object sender, EventArgs e) { // Initialise backup client backupClient = new BackupClient(this.settings.ServerUrl, this.settings.AuthenticationKey, this.settings.CertificateIdentity); backupClient.Error += (s, er) => { ShowError(er.Message); }; backupClient.OperationChange += (s, op) => { this.Invoke(new OperationChangeEvent(UpdateCurrentOperation), new object[] { op.OperationNo, op.OperationCount, op.Operation }); }; backupClient.Progress += (s, pr) => { this.Invoke(new ProgressEvent(UpdateProgress), new object[] { pr.ProgressPercentage }); }; // Toggle Start & Cancel buttons this.StartButton.Enabled = false; this.CancelButton.Enabled = true; // Reset progress bar this.StatusProgressBar.Value = 0; // Start backup operating async this.startEvent.BeginInvoke(OnBackupComplete, null); // Reset the cancelled & error flags this.cancelled = false; this.error = false; }
public async Task <ServerData> GetBackupData() { ServerData Data = null; try { string strUri = _configuration.GetValue <string>("BackupAPI"); BackupClient client = new BackupClient(); Data = await client.GetBackupData(strUri); if (Data != null) { Data.ActionMessage = "Passthrough Action"; } } catch (Exception e) { Console.Write("Exception loading Backup Server client", e); } return(Data); }
/// <summary> /// Function to log into the ricloud API for a specified Apple ID and password, fetch a list of devices and display data for the selected device /// </summary> /// <param name="mEmail">Email address of the Apple ID to access</param> /// <param name="mPassword">Password for the aformentioned Apple ID</param> static void doProgram(string mEmail, string mPassword) { // Instantiate ricloud object ricloud mClient = new ricloud(API_KEY_USERNAME, API_KEY_PASSWORD); // Log in with specified Apple ID username and password try { mClient.Login(mEmail, mPassword); } catch (TwoFactorAuthenticationRequiredException te) { // The Apple ID has two-factor authentication enabled. Handle this by specifying a trusted device to send a 2FA code to and then passing that code back to the API dynamic mTrustedDevice = ChooseTrustedDevice(mClient.TrustedDevices); mClient.Request2FAChallenge(mTrustedDevice); string mCode = Get2FACode(); mClient.Submit2FAChallenge(mCode); mClient.Login(mEmail, mPassword); } string mDeviceId = ChooseDevice(mClient.Devices); // Choose the data to extract from the specified device. Use the bitwise flags in the BackupClient class to define this. Console.WriteLine("Data to extract:"); foreach (KeyValuePair <int, string> kvpData in BackupClient.AVAILABLE_DATA) { Console.WriteLine("{0} - {1}", kvpData.Key, kvpData.Value); } Console.WriteLine("Choose the data mask you want (use 0 for everything):"); string mMaskString = Console.ReadLine(); int mMask = -1; int.TryParse(mMaskString, out mMask); // Instantiate backup client BackupClient mBackupClient = new BackupClient(mClient); // Use backup client to fetch specified data for chosen device dynamic json = mBackupClient.RequestData(mDeviceId, mMask); // Create folder to dump results into DirectoryInfo newDir = Directory.CreateDirectory(Path.Combine(System.Environment.CurrentDirectory, "out")); // Dump JSON File.WriteAllText(Path.Combine(newDir.FullName, "data.json"), json.ToString()); // If we are getting photos if ((mMask & BackupClient.DATA_PHOTOS) == BackupClient.DATA_PHOTOS) { // Loop through photos string picfilePath; byte[] picfileData; foreach (dynamic photo in json.photos) { picfilePath = Path.Combine(newDir.FullName, photo.filename.ToString()); picfileData = mBackupClient.DownloadFile(mDeviceId, photo.file_id.ToString()); if (picfileData != null) { File.WriteAllBytes(picfilePath, picfileData); } } } Console.WriteLine("Complete! All data written to the directory " + newDir.FullName); }
public BackupClientDelegate( BackupClient backupClient) { m_backupClient = backupClient; }
//----------------------------------------------------------------------------- // backup //----------------------------------------------------------------------------- /// <summary> /// Performs the backup operation. The <paramref name="sBackupPath"/> and /// <paramref name="backupClient"/> parameters are mutually exclusive. If /// backupClient is null, then the backup will be created on disk in the /// location specified by sBackupPath. If backupClient is non-null, the /// sBackupPath parameter is ignored. /// </summary> /// <param name="sBackupPath"> /// The full pathname where the backup set is to be created. This parameter /// is ignored if the backupClient parameter is non-null. /// </param> /// <param name="sPassword"> /// Password to be used for the backup. A non-empty password allows the backup /// to be restored on a machine other than the one where the database exists. The /// database's encryption key (if encryption is enabled) will be wrapped in the /// specified password so that the backup can be restored to a different machine. /// </param> /// <param name="backupClient"> /// If non-null, the backupClient is an object the provides interfaces for storing /// backup data to disk, tape, or other media. If null, the backup data is stored /// to a file set specified by the sBackupPath parameter. /// </param> /// <param name="backupStatus"> /// If non-null, the backupStatus object provides an interface that this method /// calls to report backup progress. /// </param> /// <returns> /// Returns a sequence number for this backup. This is for informational /// purposes only. For instance, users can use it to label their backup tapes. /// </returns> public uint backup( string sBackupPath, string sPassword, BackupClient backupClient, BackupStatus backupStatus) { RCODE rc; uint uiSeqNum; BackupClientDelegate backupClientDelegate = null; BackupClientCallback fnBackupClient = null; BackupStatusDelegate backupStatusDelegate = null; BackupStatusCallback fnBackupStatus = null; if (backupClient != null) { backupClientDelegate = new BackupClientDelegate( backupClient); fnBackupClient = new BackupClientCallback( backupClientDelegate.funcBackupClient); } if (backupStatus != null) { backupStatusDelegate = new BackupStatusDelegate( backupStatus); fnBackupStatus = new BackupStatusCallback( backupStatusDelegate.funcBackupStatus); } if ((rc = xflaim_Backup_backup( m_pBackup, sBackupPath, sPassword, out uiSeqNum, fnBackupClient, fnBackupStatus)) != 0) { throw new XFlaimException( rc); } return( uiSeqNum); }
public void Setup() { backupClient = new BackupClient(); }