snapshot_backup
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| snapshot_backup [2011/09/20 20:50] – [C0D3s] k2patel | snapshot_backup [2020/08/10 02:35] (current) – external edit 127.0.0.1 | ||
|---|---|---|---|
| Line 8: | Line 8: | ||
| * perl | * perl | ||
| * Net:: | * Net:: | ||
| + | * DBI:SQLite | ||
| * bash | * bash | ||
| Line 20: | Line 21: | ||
| * delete_snap.pl | * delete_snap.pl | ||
| - | ==== C0D3s ==== | + | ===== C0D3s ===== |
| - | === config === | + | ==== config |
| <code bash | config > | <code bash | config > | ||
| Line 32: | Line 33: | ||
| </ | </ | ||
| - | === db.pl === | + | ==== bash config ==== |
| + | <code bash | config_bash> | ||
| + | # this file contain what need to be backup. | ||
| + | # Follow the format of value | ||
| + | # instance< | ||
| + | |||
| + | instance1=" | ||
| + | instance2=" | ||
| + | </ | ||
| + | |||
| + | ==== db.pl ==== | ||
| <code perl | db.pl > | <code perl | db.pl > | ||
| Line 99: | Line 110: | ||
| </ | </ | ||
| - | === backup.sh === | + | ==== backup.sh |
| <code bash | backup.sh> | <code bash | backup.sh> | ||
| Line 113: | Line 124: | ||
| ##################################### | ##################################### | ||
| - | source config_bash | ||
| - | BASE=$(pwd) | ||
| BASE=" | BASE=" | ||
| cd $BASE | cd $BASE | ||
| + | |||
| + | source config_bash | ||
| + | |||
| DATE=$(date +%Y%m%d) | DATE=$(date +%Y%m%d) | ||
| perl=$(which perl) | perl=$(which perl) | ||
| Line 169: | Line 181: | ||
| done | done | ||
| </ | </ | ||
| + | |||
| + | |||
| + | ==== create snapshot ==== | ||
| + | |||
| + | <code perl | create_snap.pl> | ||
| + | # | ||
| + | # Created / written by k2patel@hotmail.com | ||
| + | # this script create snapshot for given volume. | ||
| + | |||
| + | use Data:: | ||
| + | use strict; | ||
| + | #use Date::Calc qw( :all ); | ||
| + | |||
| + | use lib "/ | ||
| + | use Net:: | ||
| + | |||
| + | # Configuration. | ||
| + | require " | ||
| + | |||
| + | # our $ec2; | ||
| + | our $awsId; | ||
| + | our $awsKey; | ||
| + | our $awsinstance; | ||
| + | |||
| + | my($num_args) = $#ARGV + 1; | ||
| + | if ($num_args < 2) { | ||
| + | print " | ||
| + | print "This will create Snapshot for given Volume\n"; | ||
| + | print " | ||
| + | exit 1; | ||
| + | } | ||
| + | |||
| + | ## Define Access Keys for Amazon. | ||
| + | my $ec2 = Net:: | ||
| + | AWSAccessKeyId => $awsId, | ||
| + | SecretAccessKey => $awsKey | ||
| + | ); | ||
| + | |||
| + | my @result = $ec2-> | ||
| + | VolumeId => $ARGV[0], | ||
| + | Description => $ARGV[1] | ||
| + | ); | ||
| + | |||
| + | print $result[0]-> | ||
| + | #print Dumper \@result; | ||
| + | </ | ||
| + | |||
| + | ==== delete shnapshot ==== | ||
| + | <code perl | delete_snap.pl> | ||
| + | # This script delete snapshot of requested volume | ||
| + | # Author : k2patel < | ||
| + | # Please send me message for suggestion or update. | ||
| + | |||
| + | # this script delete snapshot | ||
| + | |||
| + | use Data:: | ||
| + | use strict; | ||
| + | #use Date::Calc qw( :all ); | ||
| + | |||
| + | use lib "/ | ||
| + | use Net:: | ||
| + | |||
| + | # Configuration. | ||
| + | require " | ||
| + | |||
| + | # our $ec2; | ||
| + | our $awsId; | ||
| + | our $awsKey; | ||
| + | our $awsinstance; | ||
| + | |||
| + | my($num_args) = $#ARGV + 1; | ||
| + | if ($num_args < 1) { | ||
| + | print " | ||
| + | print "This will Delete Snapshot\n"; | ||
| + | exit 1; | ||
| + | } | ||
| + | |||
| + | ## Define Access Keys for Amazon. | ||
| + | my $ec2 = Net:: | ||
| + | AWSAccessKeyId => $awsId, | ||
| + | SecretAccessKey => $awsKey | ||
| + | ); | ||
| + | |||
| + | my @result = $ec2-> | ||
| + | SnapshotId => $ARGV[0] | ||
| + | ); | ||
| + | |||
| + | |||
| + | if ( $result[0] eq 1 ){ | ||
| + | #print "Good to go \n"; | ||
| + | exit 0; | ||
| + | }else{ | ||
| + | my $err = Dumper \@result; | ||
| + | open F,"> | ||
| + | print F $err; | ||
| + | close F; | ||
| + | if(system ("/ | ||
| + | unlink " | ||
| + | } | ||
| + | exit 1; | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ==== Check Snapshot status ==== | ||
| + | <code perl | snap_status.pl > | ||
| + | # This script check status of given snapshot and wait for it get completed. | ||
| + | # Author : k2patel < | ||
| + | # Please send me message for suggestion or update. | ||
| + | |||
| + | |||
| + | use Data:: | ||
| + | use strict; | ||
| + | #use Date::Calc qw( :all ); | ||
| + | |||
| + | use lib "/ | ||
| + | use Net:: | ||
| + | |||
| + | # Configuration. | ||
| + | require " | ||
| + | |||
| + | # our $ec2; | ||
| + | our $awsId; | ||
| + | our $awsKey; | ||
| + | our $awsinstance; | ||
| + | |||
| + | my($num_args) = $#ARGV + 1; | ||
| + | if ($num_args < 1) { | ||
| + | print " | ||
| + | print "This will check Snapshot Status\n"; | ||
| + | exit 1; | ||
| + | } | ||
| + | |||
| + | ## Define Access Keys for Amazon. | ||
| + | my $ec2 = Net:: | ||
| + | AWSAccessKeyId => $awsId, | ||
| + | SecretAccessKey => $awsKey | ||
| + | ); | ||
| + | |||
| + | my @result = $ec2-> | ||
| + | SnapshotId => $ARGV[0] | ||
| + | ); | ||
| + | |||
| + | while ( $result[0][0]-> | ||
| + | sleep 10; | ||
| + | } | ||
| + | |||
| + | if ( $result[0][0]-> | ||
| + | my $tst = "Good to go \n"; | ||
| + | exit 0; | ||
| + | }else{ | ||
| + | my $err = Dumper \@result; | ||
| + | open F,"> | ||
| + | print F $err; | ||
| + | close F; | ||
| + | if(system ("/ | ||
| + | unlink " | ||
| + | } | ||
| + | exit 1; | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | ==== Machine DB ==== | ||
| + | |||
| + | <code bash> | ||
| + | sqlite3 machine.db | ||
| + | </ | ||
| + | |||
| + | <code sql | machine.db> | ||
| + | PRAGMA foreign_keys=OFF; | ||
| + | BEGIN TRANSACTION; | ||
| + | CREATE TABLE DESK ( v_ID, s_ID, Dte ); | ||
| + | </ | ||
| + | |||
snapshot_backup.1316551826.txt.gz · Last modified: 2020/08/10 02:29 (external edit)
