User Tools

Site Tools


snapshot_backup

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
snapshot_backup [2011/09/23 15:17]
k2patel [create snapshot]
snapshot_backup [2011/09/23 15:29]
k2patel [backup.sh]
Line 38: Line 38:
 # instance<​serial number must be unique> = <Volume ID> <​Retention Freq.> <total Retention>​ # instance<​serial number must be unique> = <Volume ID> <​Retention Freq.> <total Retention>​
  
-#instance1="​vol-2222pqrs 7 2" +instance1="​vol-2222pqrs 7 2" 
-#instance2="​vol-1111abcd 1 1"+instance2="​vol-1111abcd 1 1"
 </​code>​ </​code>​
  
Line 123: Line 123:
 #####################################​ #####################################​
  
-source config_bash 
  
-BASE=$(pwd) 
 BASE="​$( cd "$( dirname "​$0"​ )" && pwd )" BASE="​$( cd "$( dirname "​$0"​ )" && pwd )"
 cd $BASE cd $BASE
 +
 +source config_bash
 +
 DATE=$(date +%Y%m%d) DATE=$(date +%Y%m%d)
 perl=$(which perl) perl=$(which perl)
Line 275: Line 276:
  print F $err;  print F $err;
  close F;  close F;
- if(system ("/​bin/​mail -s \"​ERROR : Dump Of Error\" ​kpatel\@mcfapps.com < ./​rnd895896"​) == 0){+ if(system ("/​bin/​mail -s \"​ERROR : Dump Of Error\" ​k2patel\@hotmail.com < ./​rnd895896"​) == 0){
  unlink "​./​rnd895896";​  unlink "​./​rnd895896";​
  }  }
Line 281: Line 282:
  }  }
 </​code>​ </​code>​
 +
 +==== Check Snapshot status ====
 +<code perl | snap_status.pl >
 +# This script check status of given snapshot and wait for it get completed.
 +# Author : k2patel <​k2patel@hotmail.com>​
 +# Please send me message for suggestion or update.
 +
 +
 +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 < 1) {
 +  print "​\nUsage:​ snap_status.pl <​Snapshot_ID>​\n";​
 +  print "This will check Snapshot Status\n";​
 +  exit 1;
 +}
 +
 +## Define Access Keys for Amazon.
 +my $ec2 = Net::​Amazon::​EC2->​new(
 +        AWSAccessKeyId => $awsId, ​
 +        SecretAccessKey => $awsKey
 +);
 +
 +my @result = $ec2->​describe_snapshots(
 +SnapshotId => $ARGV[0]
 +);
 +
 +while ( $result[0][0]->​{status} ne '​completed'​ ){
 + sleep 10;
 +}
 +
 +if ( $result[0][0]->​{status} eq '​completed'​ ){
 + my $tst = "Good to go \n";
 + exit 0;
 +}else{
 + my $err = Dumper \@result;
 + open F,">​./​rnd892346";​
 + print F $err;
 + close F;
 + if(system ("/​bin/​mail -s \"​ERROR : Dump Of Error\"​ k2patel\@hotmail.com < ./​rnd892346"​) == 0){
 + unlink "​./​rnd892346";​
 + }
 + exit 1;
 + }
 +</​code>​
 +
 +==== Machine DB ====
 +
 +<code bash>
 +sqlite3 machine.db
 +</​code>​
 +
 +<code sql | machine.db>​
 +PRAGMA foreign_keys=OFF;​
 +BEGIN TRANSACTION;​
 +CREATE TABLE DESK ( v_ID, s_ID, Dte );
 +</​code>​
 +
snapshot_backup.txt · Last modified: 2020/08/10 02:35 (external edit)