The following sample illustrates how to use the backupmBinding.backup_env
method to create a backup of a Virtuozzo Container.
Sample Function Parameters:
Name |
Description |
|
The Server ID of the source Container. |
|
Backup description. |
|
Backup type:
|
|
Compression level:
|
|
The following parameters are used to specify the backup server connection and login information. The sample function provided here illustrates how to specify the backup server connection and login information manually. Note: To use a remote computer as a backup server, you must install Virtuozzo Containers software on it. |
|
Backup server IP address. |
|
Login name. |
|
Login password. |
|
Realm ID against which to authenticate the user. The Realm definition must exist in the Agent configuration on the backup server. On a fresh Agent installation, the only Realm available is |
|
Communication protocol:
|
|
Port number. Agent on the source server will be connecting to the Agent on the backup server, the TCP port numbers therefore are the standard Agent options: 4433 -- TCP/IP connection. 4434 -- SSL over TCP/IP connection.
|
Sample Function:
/// <summary>
/// Sample function BackupVE.
/// Performs a Container backup.
/// </summary>
/// <param name="eid">Server ID of the source Container.</param>
/// <param name="description">
/// User-defined backup description.
/// </param>
/// <param name="type">Backup type.</param>
/// <param name="compression">Compression level.</param>
/// <param name="ip">Target HN IP address.</param>
/// <param name="user">
/// User name with which to login to
/// the target Nardware Node.
/// </param>
/// <param name="password">User password.</param>
/// <param name="realm">Realm ID.</param>
/// <param name="protocol">Communication protocol.</param>
/// <param name="port">Target HN port number</param>
/// <returns>Backup ID.</returns>
///
public string BackupVE(string eid, string description, int type, int compression, string ip, string user, string password, string realm, string domain, string protocol, uint port)
{
try {
// Instantiate the proxy class
backupmBinding backupm = (backupmBinding)binder.InitBinding(typeof(backupmBinding));
// The main input object.
backup_env backup_input = new backup_env();
// Set Server ID of the Container.
backup_input.env_list = new string[1];
backup_input.env_list[0] = eid;
// Set backup options.
backup_optionsType options = new backup_optionsType();
// Backup description.
options.description = System.Text.ASCIIEncoding.ASCII.GetBytes(description);
// Backup type.
options.typeSpecified = true;
options.type = type;
// Compression level.
options.compressionSpecified = true;
options.compression = compression;
// Set the backup server login information.
auth_nameType login_info = new auth_nameType();
// User name.
login_info.name = System.Text.ASCIIEncoding.ASCII.GetBytes(user);
// Realm ID.
login_info.realm = realm;
// Domain name.
login_info.domain = System.Text.ASCIIEncoding.ASCII.GetBytes(domain);
// Set the backup server connection information.
connection_infoType connection = new connection_infoType();
// Backup server IP address.
connection.address = ip;
// Communication protocol.
connection.protocol = protocol;
// Port number.
connection.portSpecified = true;
connection.port = port;
// Password.
connection.password = System.Text.ASCIIEncoding.ASCII.GetBytes(password);
// Finalize the input.
connection.login = login_info;
backup_input.backup_server = connection;
backup_input.backup_options = options;
// Set infinite timeout for the request.
backupm.Timeout = -1;
// Start backup.
return backupm.backup_env(backup_input)[0].id;
}
catch (Exception e) {
return "Exception: " + e.Message;
}
}
The function invocation example:
createBackup( "ac57a9c3-573b-481a-b398-d2fb0467cf4b", "my backup", 0, 0, "10.16.3.80", "root", "my_password", "00000000-0000-0000-0000-000000000000", "TCP", 4433 );