This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
snapshot_backup [2011/09/20 20:50] k2patel [C0D3s] |
snapshot_backup [2011/09/23 15:14] k2patel [bash config] |
||
---|---|---|---|
Line 32: | Line 32: | ||
</code> | </code> | ||
- | === db.pl === | + | ==== bash config ==== |
+ | <code bash | config_bash> | ||
+ | # this file contain what need to be backup. | ||
+ | # Follow the format of value | ||
+ | # instance<serial number must be unique> = <Volume ID> <Retention Freq.> <total Retention> | ||
+ | |||
+ | #instance1="vol-2222pqrs 7 2" | ||
+ | #instance2="vol-1111abcd 1 1" | ||
+ | </code> | ||
+ | |||
+ | ==== db.pl ==== | ||
<code perl | db.pl > | <code perl | db.pl > | ||
Line 99: | Line 109: | ||
</code> | </code> | ||
- | === backup.sh === | + | ==== backup.sh ==== |
<code bash | backup.sh> | <code bash | backup.sh> | ||
Line 168: | Line 178: | ||
fi | fi | ||
done | done | ||
+ | </code> | ||
+ | |||
+ | |||
+ | ==== create snapshot ==== | ||
+ | |||
+ | <code perl | create_snap.pl> | ||
+ | #!/usr/bin/perl -w | ||
+ | # Created / written by k2patel@hotmail.com | ||
+ | # this script create snapshot for given volume. | ||
+ | |||
+ | use Data::Dumper; | ||
+ | use strict; | ||
+ | #use Date::Calc qw( :all ); | ||
+ | |||
+ | use lib "/usr/share/perl5/vendor_perl"; | ||
+ | use Net::Amazon::EC2; | ||
+ | |||
+ | # Configuration. | ||
+ | require "config"; | ||
+ | |||
+ | # our $ec2; | ||
+ | our $awsId; | ||
+ | our $awsKey; | ||
+ | our $awsinstance; | ||
+ | |||
+ | my($num_args) = $#ARGV + 1; | ||
+ | if ($num_args < 2) { | ||
+ | print "\nUsage: create_snap.pl <Volume_ID> <Today>\n"; | ||
+ | print "This will create Snapshot for given Volume\n"; | ||
+ | print "Format for today's Date must be \"YYYYMMDD\"\n"; | ||
+ | exit 1; | ||
+ | } | ||
+ | |||
+ | ## Define Access Keys for Amazon. | ||
+ | my $ec2 = Net::Amazon::EC2->new( | ||
+ | AWSAccessKeyId => $awsId, | ||
+ | SecretAccessKey => $awsKey | ||
+ | ); | ||
+ | |||
+ | my @result = $ec2->create_snapshot( | ||
+ | VolumeId => $ARGV[0], | ||
+ | Description => $ARGV[1] | ||
+ | ); | ||
+ | |||
+ | print $result[0]->{snapshot_id}; | ||
+ | #print Dumper \@result; | ||
</code> | </code> |