To restore a Container from a backup archive, you first have to obtain its ID. The backup that you are restoring from must be one of the following:
By default, the Container will be restored on the Hardware Node that you are currently connected to. When you are restoring a Container in a Virtuozzo group, an attempt will be made to restore it to the original Node. If the original Node is no longer registered with the group, you'll have to set the target Node manually or the operation will fail. Regardless of the conditions under which the restore operation is performed, the resulting Container will always have the same Server ID as the original Container.
The samples in this section illustrates how to use the backupmBinding.restore_env
method to restore a Container from a backup archive. The following sample function accepts a local backup ID and restores a Container on the current Hardware Node.
Sample Function:
/// <summary>
/// Sample function RestoreBackup.
/// Restores a Container from a backup.
/// </summary>
/// <param name="backup_id">Backup ID.</param>
/// <returns>"OK" or error information.</returns>
///
public string RestoreBackup(string backup_id) {
string list_result = "";
try {
backupmBinding backupm = (backupmBinding)binder.InitBinding(typeof(backupmBinding));
// The main input object.
restore_env restore = new restore_env();
// Set backup id.
restore.backup_id = backup_id;
// Start restore.
backupm.restore_env(restore);
return "OK!";
}
catch (Exception e) {
list_result += "Exception: " + e.Message;
}
return list_result;
}
The following sample shows how to restore a Container from a remote backup. In it, we pass the backup ID and the backup server connection and login information.
Sample Function Parameters:
Name |
Description |
|
Backup ID. |
|
The rest of the parameters specify the remote backup server connection and login information. |
|
IP address. |
|
User name. |
|
Realm ID. |
|
TCP port number. |
|
Communication protocol. |
|
User password. |
Sample Function:
/// <summary>
/// Sample function RestoreRemoteBackup.
/// Restores a Container from a remotely stored backup.
/// </summary>
/// <param name="backup_id">Backup ID.</param>
/// <param name="ip">Remote HN IP address.</param>
/// <param name="user">
/// User name with which to login to the remote HN node.
/// </param>
/// <param name="realm">Realm ID.</param>
/// <param name="port">Port number.</param>
/// <param name="protocol">Communication protocol.</param>
/// <param name="password">Password.</param>
/// <returns>"OK" or error information.</returns>
///
public string RestoreRemoteBackup(string backup_id, string ip, string user, string realm, uint port, string protocol, string password)
{
string list_result = "";
try {
// Instantiate the proxy class
backupmBinding backupm = (backupmBinding)binder.InitBinding(typeof(backupmBinding));
// The main input object.
restore_env restore = new restore_env();
//Set backup id.
restore.backup_id = backup_id;
// The backup server connection info.
connection_infoType connection = new connection_infoType();
// Set IP address.
connection.address = ip;
auth_nameType name = new auth_nameType();
// Set user name.
name.name = System.Text.ASCIIEncoding.ASCII.GetBytes(user);
// Set Realm ID.
name.realm = realm;
// Set port number.
connection.portSpecified = true;
connection.port = port;
// Set communication protocol name.
connection.protocol = protocol;
connection.login = name;
// Set user password.
connection.password = System.Text.ASCIIEncoding.ASCII.GetBytes(password);
// Finalize the backup server connection and login
// parameters.
restore.backup_server = connection;
// Start restore.
backupm.restore_env(restore);
return "OK!";
}
catch (Exception e) {
list_result += "Exception: " + e.Message;
}
return list_result;
}
The function invocation example:
restoreBackup("85a2dd71-9133-7c44-8521-f6bd517f17ca/0", "10.16.3.80", "root", "my_password", "00000000-0000-0000-0000-000000000000", "TCP", 4433);