Getting EBS Snapshot with BackUp Monkey [ a python utility ]
It’s a command line utility written in python that uses boto library.
- To create snapshot of all the Elastic Block Storage volume’s (EBS).
- Automatically detects the volume in the region and take the backup.
- It is especially designed for Amazon Web Services.
- It can be scheduled using CRON.
Backup_Monkey can be installed easily using “pip” utility . pip is basically a tool for installing python packages.
sudo pip install backup_monkey
Backup_Monkey requires some configuration settings.
This utility uses boto. “boto” is an API written in python, which is used to call AWS resources. Calling AWS resources requires either an IAM user credentials or IAM role with valid resource access. For this purpose, we need to have an IAM user with the EC2 Full Access Policy. You can also customize it according to your needs.
Create a .boto file in your $HOME directory and add the AWS_CREDENTIALS to it :
aws_access_key_id = <your_access_key_here>
$ backup-monkey -help
$ backup-monkey --region us-west-2 //Replace with your region
Backup_Monkey command once runs takes snapshot as well delete an older snapshot. This is configured to keep 3 snapshot/volume and automatically deletes the older one. But this can be changed by changing the default value to whatever you want in the below listed file. It Depend’s on your use case
Scheduling CRON for Backup_Monkey :
0 0 * * * /home/ubuntu/script/backup_monkey.sh >> /home/ubuntu/script/backup_monkey.logs 2>&1
Every midnight the backup will be automatically created.
There is one issue with this utility is that it uses a self_prefix value “BACKUP_MONKEY” as snapshot name which you can see in the Output Section which I will be fixing in the next article with the name of your instance instead of self_prefix.
” Use this monkey to automate your backup task ! ”