Exploring the Veeam API with Python

I have recently been experimenting and testing the Veeam API, however, I have noticed that there is a lack of information on how to work with it especially if you are new to the subject.

I love Python so it made sense to explorer the API using this, however, trying to communicate how to use it is a bit of a challenge. Enter Jupyter Notebooks.

If you are not already familiar with these, they essentially allow you to enter both markdown text and executeable python code into notebook ‘cells’.

The Markdown areas allow you to provide explaination of what you are doing in a logical fashion which makes it ideal for this type of use.

You can install Jupyter Labs which is the latest incarnation of Notebooks using:

pip install jupyterlab

You will need Python installed on your system (with it included in your PATH variables) for this to work. You then just need to run:

jupyter-lab

Alternativtley VS Code has direct support for Jupyter Notebooks so you can run them in there if you wish. Personally I find the Labs looks nicer but VS Code has intellisense which can be very useful.

I have uploaded a JP Notebook to my github which can be viewed here:

https://github.com/shapedthought/juypter_veeam_api

Creating an S3 bucket for Veeam with immutability

I have been often asked how to set up a bucket with immuntibilty enabled to allow for connection to Veeam. This is incredibly easy but appears on the surface as complicated.

The steps are as follows:

  1. Create your bucket.
  2. Enable Object Lock
  3. Create a new user with S3 permissions
  4. Grab access credentials

See how easy is that! Oh, you want a step by step guide? Ok…

First go to S3 in the AWS console and press ‘Create Bucket’

Give the bucket a name and set the region.

Ensure that public access is blocked

Enable verioning (this is required to enable Object Lock)

Next click ‘Advanced Settings’ and Enable Object lock

You will need to read the warning and type ‘enable’, then hit ‘create’ and you are done!

Note that if you go into the newly created bucket and then to ‘properties’ > ‘ Advanced settings’ > ‘Obect lock’ you will see this.

Do not enabled compliance mode as it is not required within the AWS interface. Veeam applies the approrpate flags in the upload via the API.

Next you need to create a user with access limited to S3 only. First got to IAM > Users > Create a new user.

Give it a name and Programmatic access.

Then go Next, press Add a Group, give it a name and then search for ‘AmazonS3FullAccess’ then press ‘Create Group’.

Add Tags if required > Summary > Create User.

This will then show you the Access key ID and Secret access key required to add the object storage to Veeam.

I hope this helps!

Migrating Veeam Backups from AWS to Azure

This article shows you how you can migrate backups that have been copy/tiered to AWS S3 storage and that you want to move to Azure.

The process of moving backups from AWS to Azure is very well covered in this video by Thomas Mauer.

This involves using Azure Azcopy to move the data which is relatively easy to do.

The interest piece is what you need to do in order to bring those backups backup into Veeam. Note that this is based on my personal tests up to this point and these may change as I do more.

To start the process you need to add the freshly migrated object storage in VBR via the usual Backup Infrastructure > Add Repository > Object Storage > Azure. Now, you would have thought that doing this would allow you to bring import that backups.

However what I have found with this is that any backups that are present in the repository are ‘skipped’.

I testing removing the existing copy of the backups from the capacity (cloud) tier of the SOBR, this had the same result. (Note you need to disable copy tiering before doing this or VBR will attempt to reupload them). I haven’t at this point attempted to seal the capacity tier which may work and is certainly less daunting than deleting all the capacity tier backups.

I then removed the local copies of the backups as well, this had the desired effect allowing the Azure object based backups to be imported. This extent was then added to a new SORB, this moved the object backup from Object Storage (Imported) to Object Storage. I believe the reason why it will not add the backup from the object storage is because the backup is already in VBR’s configuration database.

The next challenge was reconnecting the backup job, I did this by going into the existing backups job and mapping the backup to the new SOBR.

if you try to do this on just capacity tier alone it will fail.

So before doing this you will need to download the last backup chain to your performance tier. This can be done by going to: Home > Object Storage > Right Click Job name > Properties. You can then right-click on a cloud backup and it will ask if you wish to download just the individual bacup or the whole backup chain. This will then allow you to carry on with the backup chain like normal.

Further information on how to do this can be found here. https://helpcenter.veeam.com/docs/backup/vsphere/downloading_from_capacity_tier.html?ver=100

Hope this helps someone!

Keep coding 🙂