AWS EC2 EBS Automatic Snapshot BASH

techShihab

How it works: ebs-snapshot.sh will:

  • Determine the instance ID of the EC2 server on which the script runs
  • Transferring the data via rsync to EBS volume which we attached.
  • Create snapshot of volume which we mentioned the script.
  • The script will then delete all associated snapshots taken by the script that are older than 7 days

REQUIREMENTS

  • IAM User
  • AWS CLI
  • Create EBS volume and attach to EC2 instance which we want to take data backup and mount.
  • Script: Create file and copy snapshot script, then Change the below lines as per need and make it executable. In order to schedule a backup we can setup a cron job.
  • Change the lines rsync -av –stats –delete –numeric-ids /EC2 data folder /EBS volume mount point and volume_list=”EBS ID” as per your need and configuration.
  • Script

    #!/bin/bash

    export PATH=$PATH:/usr/local/bin/:/usr/bin

    # Safety feature: exit script if error is returned, or if variables not…

    View original post 480 more words

    Advertisements

    Leave a Reply

    Fill in your details below or click an icon to log in:

    WordPress.com Logo

    You are commenting using your WordPress.com account. Log Out / Change )

    Twitter picture

    You are commenting using your Twitter account. Log Out / Change )

    Facebook photo

    You are commenting using your Facebook account. Log Out / Change )

    Google+ photo

    You are commenting using your Google+ account. Log Out / Change )

    Connecting to %s