Backup Examples

Getting a node from a compute driver and enabling backup

This example shows how to get a node using a remote Azure datacenter, enable backup and backup the node.


This example works with Libcloud version 0.20.0 and above.

import time
from pprint import pprint

from libcloud.backup.types import BackupTargetJobStatusType
from libcloud.backup.types import Provider as BackupProvider
from libcloud.backup.providers import get_driver as get_backup_driver

from libcloud.compute.providers import get_driver as get_compute_driver
from libcloud.compute.types import Provider as ComputeProvider

backup_driver = get_backup_driver(
    BackupProvider.DIMENSIONDATA)('username', 'api key')
compute_driver = get_compute_driver(
    ComputeProvider.DIMENSIONDATA)('username', 'api key')

nodes = compute_driver.list_nodes()

# Backup the first node in the pool
selected_node = nodes[0]

print('Enabling backup for node')
new_target = backup_driver.create_target_from_node(selected_node)

print('Starting backup of node')
job = backup_driver.create_target_job(new_target)

print('Waiting for job to complete')
while True:
    if job.status != BackupTargetJobStatusType.RUNNING:
        job = backup_driver.get_target_job(

    print('Job is now at %s percent complete' % (job.progress))

print('Job is completed with status- %s' % (job.status))

print('Getting a list of recovery points')
recovery_points = backup_driver.list_recovery_points(new_target)