Script for automated incremental backups

Overview

This script demonstrated in this tutorial will use public cloud APIs to communicate with the cloud and generate volume backups for all instances. You can follow the instructions to set up this script on crontab. With the help of crontab, it will run automatically every day. On the first run, this script will generate full-volume backups of all the VMs. After the first day, it will take incremental backup for 20 days. On the 21st day, the script will remove all the volume backups and generate a full volume back up again, so the cycle repeats itself every 20 days. These settings are customizable; if you need any other settings, you can open a ticket by clicking here.

Prerequisites

There are some prerequisites that need to be met before you begin:

  • Python 3

  • Instance on Public Cloud console

Get Started

Step 1: You have to create an instance first. Follow this article to create an instance.

Step 2: Download and unzip files by clicking here. This folder contains two files, variable.json, and script.py.

Please change the following fields in the variables.json file:

FieldDescription

Region

Change the value of the region 'ap-south-mum' to operate and maintain your backups in the Mumbai region.

Project ID

Mention your project id here; you can find it on the dashboard panel.

Name

Mention your cloud console username here.

Password

Mention your cloud console password here.

Name

Mention the name of your project here; you can find it on the dashboard panel under identity.

Upload both variable.json and script.py on your server.

{
    "identity-api":"https://api-us-east-at-1.openstack.acecloudhosting.com:5000",
    "comment": "--+--change the value of region to 'ap-south-mum' to operate and maintain your backups in Mumbai region--+--",
    "region": "us-east-at",
    "comment":"--+--mention your project id here, you can find it on the dashboard panel under identity--+--",
    "project_id":" ",
    "token-data":{ "auth": {
    "identity": {
    "methods": ["password"],
    "password": {
        "user": {
        "comment": "--+--mention your cloud console username here--+--",
        "name": "",
        "domain": { "id": "default" },
        "comment":"--+--mention your cloud console password here--+--",
        "password": " "
        }
    }
    },
    "scope": {
    "project": {
        "domain":{
            "id":"default"
        },
        "comment":"--+--mention the name of your project here, you can find it on the dashboard panel under identity--+--",
        "name": " "
    }
    }
    }
    }
}

Step 3: Set the execution of the script in cron.

crontab -e

When you run the above command, a file will open; add the follow line to schedule volume backup at 1:00 every day.

0 1 * * * python3 <location of script.py>

Last updated