Backing up OVH Public Cloud instances using snapshots

OVH Public Cloud platform is based on OpenStack software. As such, it has an API using which many procedures can be automated. Today I will be showing how to automatically create whole server backups using snapshots.

At first, we need to install the OpenStack Nova CLI client. This can be done by running

# pip install python-novaclient

 

Setting up authentication

Now we need to go to the OVH Manager, generate a new API key, copy the password and download configuration. The configuration file is called openrc.shand contains information like API endpoint, region and more. By default, when using this file, the system will always ask for the API password. Therefore we need to modify it and paste the password directly into the file.

Open the file and modify the password section to look like this:

# With Keystone you pass the keystone password.
#echo "Please enter your OpenStack Password: "
#read -sr OS_PASSWORD_INPUT
export OS_PASSWORD=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx # Enter the key here

With that done place the file in /root and chmod 600 /root/openrc.shto prevent unauthorized access.

 

Backing up

We can now write the actual backup script:

#!/bin/bash

# Include authentication data
source /root/openrc.sh

# Start snapshot creation
nova backup <instance_name> <instance_name>-daily-`date +%F` daily 7

Replace <instance_name> with the name of your instance as seen in the OVH Dashboard and save the file to /root/backup_daily.sh. In this configuration the system will keep only 7 latest daily backups, old ones will be automatically purged. More information can be found here.

Make the script executable chmod a+x /root/openrc.sh and run it. There should be no errors and your snapshot should be automatically created.

 

Automating backups

To automate the backup creation process, add the following into the /etc/crontab:

21 2 * * * root /root/backup_daily.sh

This will automatically launch the backup script daily at 02:21.

 

Backing up multiple servers

If you want to back up multiple servers, just add more nova backup... lines into /root/backup_daily.sh

2 thoughts on “Backing up OVH Public Cloud instances using snapshots”

  1. Hi, thank you for the comment.

    Running under a normal user account should be possible. However, remember to protect the openrc.sh file as it contains sensitive data.

Leave a Reply...