This script is designed to allow you to schedule backups of your Nova instances.
You can set a policy to retain your backups.
Since the script is written in python, it can be run from any machine on which python is installed.
You do not need to install OpenStack clients to run this script.
Retrieving the script from the Git repository:
$ git clone https://github.com/myorg92/os-nova-backup.git $ cd os-nova-backup/
Running the script requires that some environment variables be loaded:
OS_USERNAME : The user name of your OpenStack account
On Cloudwatt = email address
OS_PASSWORD : The password of your OpenStack account
OS_TENANT_ID : Identifiant of the Openstack tenant
OS_AUTH_URL : The URL of the identification service
On Cloudwatt = https://identity.fr2.cloudwatt.com/v2.0
OS_COMPUTE_URL : The URL of the Compute service
On Cloudwatt = https://compute.fr1.cloudwatt.com/v2/ « tenant-id » for fr1
https://compute.fr2.cloudwatt.com/v2/« tenant-id » for fr2
utilisation: python backup.py <server_id> <server_name> <weekly|daily> <rotation>
< server_id > ID of the instance to backup
< server_name > Name of tje backup image.
< weekly|daily > Type of backup : “daily” or “weekly”.
<rotation> Parameter Int representing the number of backups to keep
You can schedule backups via crontab or Jenkins for example. Here are 2 examples of cron task:
0 2 * * 6 python backup.py 0a49912c-1661-4d92-b469-53dfea7ce3da Myinstance weekly 4
0 2 1-5,7 * * python backup.py 0a49912c-1661-4d92-b469-53dfea7ce3da Myinstance daily 6
Backups will be named as “instance name” - “year / day / hour / minute” - “type of backup” Example: myinstance-20171281425-weekly
This is actually a snapshot that will be stored as an image in your tenant. This image can be used to launch new instances or to restore an existing instance.
This version of the script does not allow yet the restoration (rebuild). It is therefore necessary to use the CLI:
$ nova rebuild 0a49912c-1661-4d92-b469-53dfea7ce3da myinstance-20171281425-weekly