Script to automate the creation and management of EC2 EBS snapshots

What is the best way to automate (daily) snapshots of my EBS volumes (2) and manage them.

"Manage" I mean that I am looking for a script that will not only create daily backups (I assume the cron job will be enabled), but also delete snapshots that are older than x days, so that to avoid overuse of data .

I believe that such scripts really exist somewhere out there, but I don't seem to click one.

T

+3
source share
4 answers

http://awsmissingtools.com - "ec2-automate-backup", "ec2-automate-backup -s tag -t Backup-true -k 14 -p" EBS Backup = true -k - 14 , -k 14 , -k 365.

+3

. script. PHP , .

script , .

  • SSH- .
  • $ cd /usr/local/
    
  • ec2

    $ git clone https://gist.github.com/9738785.git ec2
    
  • $ cd ec2
    
  • backup.php

    $ chmod +x backup.php
    
  • releases github AWS PHP SDK URL- aws.zip. .

    $ wget https://github.com/aws/aws-sdk-php/releases/download/2.6.0/aws.zip
    
  • aws.

    $ unzip aws.zip -d aws 
    
  • backup.php php 5-12

    $dryrun     = FALSE;
    $interval   = '24 hours';
    $keep_for   = '10 Days';
    $volumes    = array('vol-********');
    $api_key    = '*********************';
    $api_secret = '****************************************';
    $ec2_region = 'us-east-1';
    $snap_descr = "Daily backup";
    
  • . script

    $ ./backup.php
    

    .

  • , cronjob.

    * 23 * * * /usr/local/ec2/backup.php
    
0

, EBS. , . , , .

, EBS ( )

Perl, https://github.com/sciclon/EBS_Snapshots

: * script (crontab)

  • ,

  • "", , .

  • , , 6 , 3, .

  • "prescript", , , , , , , "0" , , , .

    • "", (, , )

    • " ", , , " ", .

    script " ", , script IPC.

    " ", API . , .

0

Source: https://habr.com/ru/post/1780387/


All Articles