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: "
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:


# Include authentication data
source /root/

# 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/ 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/ 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/

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/


Add yours

  1. good stuff! does it have to be root for backup though?

  2. Hi, thank you for the comment.

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

Leave a Reply...