def virtuoso_backup(dict_ttSettings, s_host, l_host , l_user, backup_dir): #global dict_source_ttSettings dict_source_ttSettings = dict_ttSettings dict_target_ttSettings = 'NA' my_logger.debug("In virtuoso_backup()...") #isql_path_new = "/usr/bin/isql-vt" isql_path_old = "/usr/local/virtuoso-opensource/bin/isql" db_dir_old = "/usr/local/virtuoso-opensource/var/lib/virtuoso/db/" backup_sub_path_old = "/usr/local/virtuoso-opensource/share/virtuoso/vad/3t_backup" #backup_sub_path_new = "/usr/share/virtuoso-opensource-7.1/vad/3t_backup" #backup_sub_path = backup_sub_path_new backup_sub_path = backup_sub_path_old """********************************************************************************************************************""" """ Setting source parameters...start""" my_logger.debug("Setting source host(%s) parameters..."%s_host) my_logger.debug("s_host : %s"%s_host) if "nyc.3top.com" in s_host: s_user = l_user my_logger.debug("s_user : %s"%s_user) my_logger.debug("Skipping cert as env is NYC...") elif "aws.3top.com" in s_host: s_user = dict_source_ttSettings["ec2"]["username"] my_logger.debug("s_user : %s"%s_user) s_dev_key_file=dict_source_ttSettings["ec2"]["cert_private_key"] my_logger.debug("s_dev_key_file : %s"%s_dev_key_file) """ Setting source backup params...start""" #v_s_isql_path = isql_path_new v_s_isql_path = isql_path_old v_s_backup_subpath = backup_sub_path """ Setting source backup params...stop""" """ Setting source parameters...stop""" """********************************************************************************************************************""" """********************************************************************************************************************""" """SOURCE OPERATIONS START""" """********************************************************************************************************************""" """ Take backup on source_host...start""" if "aws.3top.com" in s_host: my_logger.debug("Found \"aws.3top.com\" in %s"%s_host) my_logger.debug("Calling one_graph_backup_aws(%s, %s, %s, %s, %s, %s)"%(v_s_backup_subpath, v_s_isql_path, s_host, s_user, s_dev_key_file, "backup")) try: graph_list = one_graph_backup_aws(v_s_backup_subpath, v_s_isql_path, s_host, s_user, s_dev_key_file, "backup") except: my_logger.error("Calling one_graph_backup_aws() failed. Exiting!") sys.exit("Calling one_graph_backup_aws() failed. Exiting!") my_logger.debug("Calling one_graph_backup_aws() Successful") elif "nyc.3top.com" in s_host: my_logger.debug("Found \"nyc.3top.com\" in %s"%s_host) my_logger.debug("Calling one_graph_backup_nyc(%s, %s, %s, %s, %s)"%(v_s_backup_subpath, v_s_isql_path, s_host, s_user, "backup")) try: graph_list = one_graph_backup_nyc(v_s_backup_subpath, v_s_isql_path, s_host, s_user, "backup") except: my_logger.error("Calling one_graph_backup_nyc() failed. Exiting!") sys.exit("Calling one_graph_backup_nyc() failed. Exiting!") my_logger.debug("Calling one_graph_backup_nyc() Successful") """ Take backup on source_host...stop""" """********************************************************************************************************************""" """ Pull backup from source_host to local...start""" if backup_dir == 'NA': """Create local source backup_before_dir...start""" #print dirTimestamp l_s_backup_before_dir = dirTimestamp + "/virtuoso-backup/s_backup_before" v_s_backup_before_dir = backup_sub_path + "/" + timestamp #print l_s_backup_before_dir if not os.path.exists(l_s_backup_before_dir): os.makedirs(l_s_backup_before_dir) """Create local source backup_before_dir...stop""" elif backup_dir != 'NA': l_s_backup_before_dir = backup_dir v_s_backup_before_dir = backup_sub_path + "/" + timestamp try: v_pull_backup_to_local(s_user, s_host, v_s_backup_before_dir, l_s_backup_before_dir) except: my_logger.error("Calling v_backup_to_local() failed. Exiting!") sys.exit("Calling v_backup_to_local() failed. Exiting!") """ Pull backup from source_host to local...stop""" """********************************************************************************************************************""" """ Delete backup on source_host...start""" if "aws.3top.com" in s_host: my_logger.debug("Found \"aws.3top.com\" in %s"%s_host) my_logger.debug("Calling delete_backup_on_aws_virtuoso(%s, %s, %s, %s, %s)"%(v_s_backup_subpath, timestamp, s_host, s_user, s_dev_key_file)) try: delete_backup_on_aws_virtuoso(v_s_backup_subpath, timestamp, s_host, s_user, s_dev_key_file) except: my_logger.error("Calling delete_backup_on_aws_virtuoso() failed. Exiting!") sys.exit("Calling delete_backup_on_aws_virtuoso() failed. Exiting!") my_logger.debug("Calling delete_backup_on_aws_virtuoso() Successful") elif "nyc.3top.com" in s_host: my_logger.debug("Found \"nyc.3top.com\" in %s"%s_host) my_logger.debug("Calling delete_backup_on_nyc_virtuoso(%s, %s, %s, %s)"%(v_s_backup_subpath, timestamp, s_host, s_user)) try: delete_backup_on_nyc_virtuoso(v_s_backup_subpath, timestamp, s_host, s_user) except: my_logger.error("Calling delete_backup_on_nyc_virtuoso() failed. Exiting!") sys.exit("Calling delete_backup_on_nyc_virtuoso() failed. Exiting!") my_logger.debug("Calling delete_backup_on_nyc_virtuoso() Successful") """ Delete backup on source_host...stop""" """********************************************************************************************************************""" """SOURCE OPERATIONS STOP""" """********************************************************************************************************************"""
def virtuoso_backup(dict_ttSettings, s_host, l_host, l_user, backup_dir): #global dict_source_ttSettings dict_source_ttSettings = dict_ttSettings dict_target_ttSettings = 'NA' my_logger.debug("In virtuoso_backup()...") #isql_path_new = "/usr/bin/isql-vt" isql_path_old = "/usr/local/virtuoso-opensource/bin/isql" db_dir_old = "/usr/local/virtuoso-opensource/var/lib/virtuoso/db/" backup_sub_path_old = "/usr/local/virtuoso-opensource/share/virtuoso/vad/3t_backup" #backup_sub_path_new = "/usr/share/virtuoso-opensource-7.1/vad/3t_backup" #backup_sub_path = backup_sub_path_new backup_sub_path = backup_sub_path_old """********************************************************************************************************************""" """ Setting source parameters...start""" my_logger.debug("Setting source host(%s) parameters..." % s_host) my_logger.debug("s_host : %s" % s_host) if "nyc.3top.com" in s_host: s_user = l_user my_logger.debug("s_user : %s" % s_user) my_logger.debug("Skipping cert as env is NYC...") elif "aws.3top.com" in s_host: s_user = dict_source_ttSettings["ec2"]["username"] my_logger.debug("s_user : %s" % s_user) s_dev_key_file = dict_source_ttSettings["ec2"]["cert_private_key"] my_logger.debug("s_dev_key_file : %s" % s_dev_key_file) """ Setting source backup params...start""" #v_s_isql_path = isql_path_new v_s_isql_path = isql_path_old v_s_backup_subpath = backup_sub_path """ Setting source backup params...stop""" """ Setting source parameters...stop""" """********************************************************************************************************************""" """********************************************************************************************************************""" """SOURCE OPERATIONS START""" """********************************************************************************************************************""" """ Take backup on source_host...start""" if "aws.3top.com" in s_host: my_logger.debug("Found \"aws.3top.com\" in %s" % s_host) my_logger.debug( "Calling one_graph_backup_aws(%s, %s, %s, %s, %s, %s)" % (v_s_backup_subpath, v_s_isql_path, s_host, s_user, s_dev_key_file, "backup")) try: graph_list = one_graph_backup_aws(v_s_backup_subpath, v_s_isql_path, s_host, s_user, s_dev_key_file, "backup") except: my_logger.error("Calling one_graph_backup_aws() failed. Exiting!") sys.exit("Calling one_graph_backup_aws() failed. Exiting!") my_logger.debug("Calling one_graph_backup_aws() Successful") elif "nyc.3top.com" in s_host: my_logger.debug("Found \"nyc.3top.com\" in %s" % s_host) my_logger.debug( "Calling one_graph_backup_nyc(%s, %s, %s, %s, %s)" % (v_s_backup_subpath, v_s_isql_path, s_host, s_user, "backup")) try: graph_list = one_graph_backup_nyc(v_s_backup_subpath, v_s_isql_path, s_host, s_user, "backup") except: my_logger.error("Calling one_graph_backup_nyc() failed. Exiting!") sys.exit("Calling one_graph_backup_nyc() failed. Exiting!") my_logger.debug("Calling one_graph_backup_nyc() Successful") """ Take backup on source_host...stop""" """********************************************************************************************************************""" """ Pull backup from source_host to local...start""" if backup_dir == 'NA': """Create local source backup_before_dir...start""" #print dirTimestamp l_s_backup_before_dir = dirTimestamp + "/virtuoso-backup/s_backup_before" v_s_backup_before_dir = backup_sub_path + "/" + timestamp #print l_s_backup_before_dir if not os.path.exists(l_s_backup_before_dir): os.makedirs(l_s_backup_before_dir) """Create local source backup_before_dir...stop""" elif backup_dir != 'NA': l_s_backup_before_dir = backup_dir v_s_backup_before_dir = backup_sub_path + "/" + timestamp try: v_pull_backup_to_local(s_user, s_host, v_s_backup_before_dir, l_s_backup_before_dir) except: my_logger.error("Calling v_backup_to_local() failed. Exiting!") sys.exit("Calling v_backup_to_local() failed. Exiting!") """ Pull backup from source_host to local...stop""" """********************************************************************************************************************""" """ Delete backup on source_host...start""" if "aws.3top.com" in s_host: my_logger.debug("Found \"aws.3top.com\" in %s" % s_host) my_logger.debug( "Calling delete_backup_on_aws_virtuoso(%s, %s, %s, %s, %s)" % (v_s_backup_subpath, timestamp, s_host, s_user, s_dev_key_file)) try: delete_backup_on_aws_virtuoso(v_s_backup_subpath, timestamp, s_host, s_user, s_dev_key_file) except: my_logger.error( "Calling delete_backup_on_aws_virtuoso() failed. Exiting!") sys.exit( "Calling delete_backup_on_aws_virtuoso() failed. Exiting!") my_logger.debug("Calling delete_backup_on_aws_virtuoso() Successful") elif "nyc.3top.com" in s_host: my_logger.debug("Found \"nyc.3top.com\" in %s" % s_host) my_logger.debug( "Calling delete_backup_on_nyc_virtuoso(%s, %s, %s, %s)" % (v_s_backup_subpath, timestamp, s_host, s_user)) try: delete_backup_on_nyc_virtuoso(v_s_backup_subpath, timestamp, s_host, s_user) except: my_logger.error( "Calling delete_backup_on_nyc_virtuoso() failed. Exiting!") sys.exit( "Calling delete_backup_on_nyc_virtuoso() failed. Exiting!") my_logger.debug("Calling delete_backup_on_nyc_virtuoso() Successful") """ Delete backup on source_host...stop""" """********************************************************************************************************************""" """SOURCE OPERATIONS STOP""" """********************************************************************************************************************"""
def virtuoso_operations(s_host, t_host, l_host , l_user): my_logger.debug("In virtuoso_operations()...") isql_path_new = "/usr/bin/isql-vt" #db_dir_old = "/usr/local/virtuoso-opensource/var/lib/virtuoso/db/" #backup_sub_path_old = "/usr/local/virtuoso-opensource/share/virtuoso/vad/3t_backup" backup_sub_path_new = "/usr/share/virtuoso-opensource-7.1/vad/3t_backup" backup_sub_path = backup_sub_path_new """********************************************************************************************************************""" """ Setting source parameters...start""" my_logger.debug("Setting source host(%s) parameters..."%s_host) my_logger.debug("s_host : %s"%s_host) if "nyc.3top.com" in s_host: s_user = l_user my_logger.debug("s_user : %s"%s_user) my_logger.debug("Skipping cert as env is NYC...") elif "aws.3top.com" in s_host: s_user = dict_source_ttSettings["ec2"]["username"] my_logger.debug("s_user : %s"%s_user) s_dev_key_file=dict_source_ttSettings["ec2"]["cert_private_key"] my_logger.debug("s_dev_key_file : %s"%s_dev_key_file) """ Setting source backup params...start""" v_s_isql_path = isql_path_new v_s_backup_subpath = backup_sub_path """ Setting source backup params...stop""" """ Setting source parameters...stop""" """********************************************************************************************************************""" """ Setting target parameters...start""" my_logger.debug("Setting target host(%s) parameters..."%t_host) my_logger.debug("t_host : %s"%t_host) if "nyc.3top.com" in t_host: t_user = l_user my_logger.debug("t_user : %s"%t_user) my_logger.debug("Skipping cert as env is NYC...") elif "aws.3top.com" in t_host: t_user = dict_target_ttSettings["ec2"]["username"] my_logger.debug("t_user : %s"%t_user) t_dev_key_file=dict_target_ttSettings["ec2"]["cert_private_key"] my_logger.debug("t_dev_key_file : %s"%t_dev_key_file) """ Setting target backup params...start""" v_t_isql_path = isql_path_new v_t_backup_subpath = backup_sub_path """ Setting target backup params...stop""" """ Setting target parameters...stop""" """********************************************************************************************************************""" """SOURCE OPERATIONS START""" """********************************************************************************************************************""" """ Take backup on source_host...start""" if "aws.3top.com" in s_host: my_logger.debug("Found \"aws.3top.com\" in %s"%s_host) my_logger.debug("Calling one_graph_backup_aws(%s, %s, %s, %s, %s, %s)"%(v_s_backup_subpath, v_s_isql_path, s_host, s_user, s_dev_key_file, "source")) try: graph_list = one_graph_backup_aws(v_s_backup_subpath, v_s_isql_path, s_host, s_user, s_dev_key_file, "source") except: my_logger.error("Calling one_graph_backup_aws() failed. Exiting!") sys.exit("Calling one_graph_backup_aws() failed. Exiting!") my_logger.debug("Calling one_graph_backup_aws() Successful") elif "nyc.3top.com" in s_host: my_logger.debug("Found \"nyc.3top.com\" in %s"%s_host) my_logger.debug("Calling one_graph_backup_nyc(%s, %s, %s, %s, %s, %s)"%(v_s_backup_subpath, v_s_isql_path, s_host, s_user, "source")) try: graph_list = one_graph_backup_nyc(v_s_backup_subpath, v_s_isql_path, s_host, s_user, "source") except: my_logger.error("Calling one_graph_backup_nyc() failed. Exiting!") sys.exit("Calling one_graph_backup_nyc() failed. Exiting!") my_logger.debug("Calling one_graph_backup_nyc() Successful") """ Take backup on source_host...stop""" """********************************************************************************************************************""" """ Pull backup from source_host to local...start""" """Create local source backup_before_dir...start""" #print dirTimestamp l_s_backup_before_dir = dirTimestamp + "/virtuoso-backup/s_backup_before" v_s_backup_before_dir = backup_sub_path + "/" + timestamp #print l_s_backup_before_dir if not os.path.exists(l_s_backup_before_dir): os.makedirs(l_s_backup_before_dir) """Create local source backup_before_dir...stop""" try: v_pull_backup_to_local(s_user, s_host, v_s_backup_before_dir, l_s_backup_before_dir) except: my_logger.error("Calling v_backup_to_local() failed. Exiting!") sys.exit("Calling v_backup_to_local() failed. Exiting!") """ Pull backup from source_host to local...stop""" """********************************************************************************************************************""" """ Delete backup on source_host...start""" if "aws.3top.com" in s_host: my_logger.debug("Found \"aws.3top.com\" in %s"%s_host) my_logger.debug("Calling delete_backup_on_aws_virtuoso(%s, %s, %s, %s, %s)"%(v_s_backup_subpath, timestamp, s_host, s_user, s_dev_key_file)) try: delete_backup_on_aws_virtuoso(v_s_backup_subpath, timestamp, s_host, s_user, s_dev_key_file) except: my_logger.error("Calling delete_backup_on_aws_virtuoso() failed. Exiting!") sys.exit("Calling delete_backup_on_aws_virtuoso() failed. Exiting!") my_logger.debug("Calling delete_backup_on_aws_virtuoso() Successful") elif "nyc.3top.com" in s_host: my_logger.debug("Found \"nyc.3top.com\" in %s"%s_host) my_logger.debug("Calling delete_backup_on_nyc_virtuoso(%s, %s, %s, %s, %s)"%(v_s_backup_subpath, timestamp, s_host, s_user)) try: delete_backup_on_nyc_virtuoso(v_s_backup_subpath, timestamp, s_host, s_user) except: my_logger.error("Calling delete_backup_on_nyc_virtuoso() failed. Exiting!") sys.exit("Calling delete_backup_on_nyc_virtuoso() failed. Exiting!") my_logger.debug("Calling delete_backup_on_nyc_virtuoso() Successful") """ Delete backup on source_host...stop""" """********************************************************************************************************************""" """SOURCE OPERATIONS STOP""" """********************************************************************************************************************""" """TARGET OPERATIONS START""" """********************************************************************************************************************""" """ Take backup on target_host...start""" if "aws.3top.com" in t_host: my_logger.debug("Found \"aws.3top.com\" in %s"%t_host) my_logger.debug("Calling one_graph_backup_aws(%s, %s, %s, %s, %s, %s)"%(v_t_backup_subpath, v_t_isql_path, t_host, t_user, t_dev_key_file, "target")) try: one_graph_backup_aws(v_t_backup_subpath, v_t_isql_path, t_host, t_user, t_dev_key_file, "target") except: my_logger.error("Calling one_graph_backup_aws() failed. Exiting!") sys.exit("Calling one_graph_backup_aws() failed. Exiting!") my_logger.debug("Calling one_graph_backup_aws() Successful") elif "nyc.3top.com" in t_host: my_logger.debug("Found \"nyc.3top.com\" in %s"%t_host) my_logger.debug("Calling one_graph_backup_nyc(%s, %s, %s, %s, %s, %s)"%(v_t_backup_subpath, v_t_isql_path, t_host, t_user, "target")) try: one_graph_backup_nyc(v_t_backup_subpath, v_t_isql_path, t_host, t_user, "target") except: my_logger.error("Calling one_graph_backup_nyc() failed. Exiting!") sys.exit("Calling one_graph_backup_nyc() failed. Exiting!") my_logger.debug("Calling one_graph_backup_nyc() Successful") """ Take backup on target_host...stop""" """********************************************************************************************************************""" """ Pull backup from source_host to local...start""" """Create local source backup_before_dir...start""" #print dirTimestamp l_t_backup_before_dir = dirTimestamp + "/virtuoso-backup/t_backup_before" v_t_backup_before_dir = backup_sub_path + "/" + timestamp #print l_s_backup_before_dir if not os.path.exists(l_t_backup_before_dir): os.makedirs(l_t_backup_before_dir) """Create local source backup_before_dir...stop""" try: v_pull_backup_to_local(t_user, t_host, v_t_backup_before_dir, l_t_backup_before_dir) except: my_logger.error("Calling v_backup_to_local() failed. Exiting!") sys.exit("Calling v_backup_to_local() failed. Exiting!") my_logger.debug("v_backup_to_local successful.") """ Pull backup from source_host to local...stop""" """********************************************************************************************************************""" """ Delete backup on source_host...start""" if "aws.3top.com" in t_host: my_logger.debug("Found \"aws.3top.com\" in %s"%t_host) my_logger.debug("Calling delete_backup_on_aws_virtuoso(%s, %s, %s, %s)"%(v_t_backup_subpath, timestamp, t_host, t_user, t_dev_key_file)) try: delete_backup_on_aws_virtuoso(v_t_backup_subpath, timestamp, t_host, t_user, t_dev_key_file) except: my_logger.error("Calling delete_backup_on_aws_virtuoso() failed. Exiting!") sys.exit("Calling delete_backup_on_aws_virtuoso() failed. Exiting!") my_logger.debug("Calling delete_backup_on_aws_virtuoso() Successful") elif "nyc.3top.com" in t_host: my_logger.debug("Found \"nyc.3top.com\" in %s"%t_host) my_logger.debug("Calling delete_backup_on_nyc_virtuoso(%s, %s, %s, %s)"%(v_s_backup_subpath, timestamp, t_host, t_user)) try: delete_backup_on_nyc_virtuoso(v_t_backup_subpath, timestamp, t_host, t_user) except: my_logger.error("Calling delete_backup_on_nyc_virtuoso() failed. Exiting!") sys.exit("Calling delete_backup_on_nyc_virtuoso() failed. Exiting!") my_logger.debug("Calling delete_backup_on_nyc_virtuoso() Successful") """ Delete backup on source_host...stop""" """********************************************************************************************************************""" """ Put backup from local to source_host...start""" """Create source_host v_t_temp_dir ...start""" #print dirTimestamp v_t_temp_dir = "/tmp/virtuoso-restore/one_graph/" + timestamp """Create local source backup_before_dir...stop""" if "aws.3top.com" in t_host: my_logger.debug("Running v_push_backup_to_aws_target(%s, %s, %s, %s) failed. Exiting!"%(t_user, t_host, l_t_backup_before_dir + "/*", t_dev_key_file, v_t_temp_dir)) try: v_push_backup_to_aws_target(t_user, t_host, l_t_backup_before_dir + "/*", t_dev_key_file, v_t_temp_dir) except: my_logger.error("v_push_backup_to_aws_target() failed. Exiting!") sys.exit("v_push_backup_to_aws_target() failed. Exiting!") my_logger.debug("v_push_backup_to_aws_target() Successful") elif "nyc.3top.com" in t_host: my_logger.debug("Running v_push_backup_to_nyc_target(%s, %s, %s, %s) failed. Exiting!"%(t_user, t_host, l_t_backup_before_dir + "/*", v_t_temp_dir)) try: v_push_backup_to_nyc_target(t_user, t_host, l_t_backup_before_dir + "/*", v_t_temp_dir) except: my_logger.error("v_push_backup_to_nyc_target() failed. Exiting!") sys.exit("v_push_backup_to_nyc_target() failed. Exiting!") my_logger.debug("v_push_backup_to_nyc_target() Successful") """ Put backup from local to source_host...stop""" """********************************************************************************************************************""" """ Put restore backup...start""" for graph in graph_list: my_logger.debug("Starting restore for graph %s in %s"%(graph, t_host)) try: v_restore_rw(t_user, t_host, t_dev_key_file, graph, v_t_temp_dir) except: my_logger.error("Restore failed for graph: %s. Exiting!"%graph) sys.exit("Restore failed for graph: %s. Exiting!"%graph) my_logger.debug("Restore for graph: %s successful!"%graph) """ Put restore backup...stop""" """********************************************************************************************************************""" """ Delete backup on ~/tmp...start""" """ Delete backup on ~/tmp...stop""" """********************************************************************************************************************"""
def virtuoso_operations(s_host, t_host, l_host, l_user): my_logger.debug("In virtuoso_operations()...") isql_path_new = "/usr/bin/isql-vt" #db_dir_old = "/usr/local/virtuoso-opensource/var/lib/virtuoso/db/" #backup_sub_path_old = "/usr/local/virtuoso-opensource/share/virtuoso/vad/3t_backup" backup_sub_path_new = "/usr/share/virtuoso-opensource-7.1/vad/3t_backup" backup_sub_path = backup_sub_path_new """********************************************************************************************************************""" """ Setting source parameters...start""" my_logger.debug("Setting source host(%s) parameters..." % s_host) my_logger.debug("s_host : %s" % s_host) if "nyc.3top.com" in s_host: s_user = l_user my_logger.debug("s_user : %s" % s_user) my_logger.debug("Skipping cert as env is NYC...") elif "aws.3top.com" in s_host: s_user = dict_source_ttSettings["ec2"]["username"] my_logger.debug("s_user : %s" % s_user) s_dev_key_file = dict_source_ttSettings["ec2"]["cert_private_key"] my_logger.debug("s_dev_key_file : %s" % s_dev_key_file) """ Setting source backup params...start""" v_s_isql_path = isql_path_new v_s_backup_subpath = backup_sub_path """ Setting source backup params...stop""" """ Setting source parameters...stop""" """********************************************************************************************************************""" """ Setting target parameters...start""" my_logger.debug("Setting target host(%s) parameters..." % t_host) my_logger.debug("t_host : %s" % t_host) if "nyc.3top.com" in t_host: t_user = l_user my_logger.debug("t_user : %s" % t_user) my_logger.debug("Skipping cert as env is NYC...") elif "aws.3top.com" in t_host: t_user = dict_target_ttSettings["ec2"]["username"] my_logger.debug("t_user : %s" % t_user) t_dev_key_file = dict_target_ttSettings["ec2"]["cert_private_key"] my_logger.debug("t_dev_key_file : %s" % t_dev_key_file) """ Setting target backup params...start""" v_t_isql_path = isql_path_new v_t_backup_subpath = backup_sub_path """ Setting target backup params...stop""" """ Setting target parameters...stop""" """********************************************************************************************************************""" """SOURCE OPERATIONS START""" """********************************************************************************************************************""" """ Take backup on source_host...start""" if "aws.3top.com" in s_host: my_logger.debug("Found \"aws.3top.com\" in %s" % s_host) my_logger.debug( "Calling one_graph_backup_aws(%s, %s, %s, %s, %s, %s)" % (v_s_backup_subpath, v_s_isql_path, s_host, s_user, s_dev_key_file, "source")) try: graph_list = one_graph_backup_aws(v_s_backup_subpath, v_s_isql_path, s_host, s_user, s_dev_key_file, "source") except: my_logger.error("Calling one_graph_backup_aws() failed. Exiting!") sys.exit("Calling one_graph_backup_aws() failed. Exiting!") my_logger.debug("Calling one_graph_backup_aws() Successful") elif "nyc.3top.com" in s_host: my_logger.debug("Found \"nyc.3top.com\" in %s" % s_host) my_logger.debug( "Calling one_graph_backup_nyc(%s, %s, %s, %s, %s, %s)" % (v_s_backup_subpath, v_s_isql_path, s_host, s_user, "source")) try: graph_list = one_graph_backup_nyc(v_s_backup_subpath, v_s_isql_path, s_host, s_user, "source") except: my_logger.error("Calling one_graph_backup_nyc() failed. Exiting!") sys.exit("Calling one_graph_backup_nyc() failed. Exiting!") my_logger.debug("Calling one_graph_backup_nyc() Successful") """ Take backup on source_host...stop""" """********************************************************************************************************************""" """ Pull backup from source_host to local...start""" """Create local source backup_before_dir...start""" #print dirTimestamp l_s_backup_before_dir = dirTimestamp + "/virtuoso-backup/s_backup_before" v_s_backup_before_dir = backup_sub_path + "/" + timestamp #print l_s_backup_before_dir if not os.path.exists(l_s_backup_before_dir): os.makedirs(l_s_backup_before_dir) """Create local source backup_before_dir...stop""" try: v_pull_backup_to_local(s_user, s_host, v_s_backup_before_dir, l_s_backup_before_dir) except: my_logger.error("Calling v_backup_to_local() failed. Exiting!") sys.exit("Calling v_backup_to_local() failed. Exiting!") """ Pull backup from source_host to local...stop""" """********************************************************************************************************************""" """ Delete backup on source_host...start""" if "aws.3top.com" in s_host: my_logger.debug("Found \"aws.3top.com\" in %s" % s_host) my_logger.debug( "Calling delete_backup_on_aws_virtuoso(%s, %s, %s, %s, %s)" % (v_s_backup_subpath, timestamp, s_host, s_user, s_dev_key_file)) try: delete_backup_on_aws_virtuoso(v_s_backup_subpath, timestamp, s_host, s_user, s_dev_key_file) except: my_logger.error( "Calling delete_backup_on_aws_virtuoso() failed. Exiting!") sys.exit( "Calling delete_backup_on_aws_virtuoso() failed. Exiting!") my_logger.debug("Calling delete_backup_on_aws_virtuoso() Successful") elif "nyc.3top.com" in s_host: my_logger.debug("Found \"nyc.3top.com\" in %s" % s_host) my_logger.debug( "Calling delete_backup_on_nyc_virtuoso(%s, %s, %s, %s, %s)" % (v_s_backup_subpath, timestamp, s_host, s_user)) try: delete_backup_on_nyc_virtuoso(v_s_backup_subpath, timestamp, s_host, s_user) except: my_logger.error( "Calling delete_backup_on_nyc_virtuoso() failed. Exiting!") sys.exit( "Calling delete_backup_on_nyc_virtuoso() failed. Exiting!") my_logger.debug("Calling delete_backup_on_nyc_virtuoso() Successful") """ Delete backup on source_host...stop""" """********************************************************************************************************************""" """SOURCE OPERATIONS STOP""" """********************************************************************************************************************""" """TARGET OPERATIONS START""" """********************************************************************************************************************""" """ Take backup on target_host...start""" if "aws.3top.com" in t_host: my_logger.debug("Found \"aws.3top.com\" in %s" % t_host) my_logger.debug( "Calling one_graph_backup_aws(%s, %s, %s, %s, %s, %s)" % (v_t_backup_subpath, v_t_isql_path, t_host, t_user, t_dev_key_file, "target")) try: one_graph_backup_aws(v_t_backup_subpath, v_t_isql_path, t_host, t_user, t_dev_key_file, "target") except: my_logger.error("Calling one_graph_backup_aws() failed. Exiting!") sys.exit("Calling one_graph_backup_aws() failed. Exiting!") my_logger.debug("Calling one_graph_backup_aws() Successful") elif "nyc.3top.com" in t_host: my_logger.debug("Found \"nyc.3top.com\" in %s" % t_host) my_logger.debug( "Calling one_graph_backup_nyc(%s, %s, %s, %s, %s, %s)" % (v_t_backup_subpath, v_t_isql_path, t_host, t_user, "target")) try: one_graph_backup_nyc(v_t_backup_subpath, v_t_isql_path, t_host, t_user, "target") except: my_logger.error("Calling one_graph_backup_nyc() failed. Exiting!") sys.exit("Calling one_graph_backup_nyc() failed. Exiting!") my_logger.debug("Calling one_graph_backup_nyc() Successful") """ Take backup on target_host...stop""" """********************************************************************************************************************""" """ Pull backup from source_host to local...start""" """Create local source backup_before_dir...start""" #print dirTimestamp l_t_backup_before_dir = dirTimestamp + "/virtuoso-backup/t_backup_before" v_t_backup_before_dir = backup_sub_path + "/" + timestamp #print l_s_backup_before_dir if not os.path.exists(l_t_backup_before_dir): os.makedirs(l_t_backup_before_dir) """Create local source backup_before_dir...stop""" try: v_pull_backup_to_local(t_user, t_host, v_t_backup_before_dir, l_t_backup_before_dir) except: my_logger.error("Calling v_backup_to_local() failed. Exiting!") sys.exit("Calling v_backup_to_local() failed. Exiting!") my_logger.debug("v_backup_to_local successful.") """ Pull backup from source_host to local...stop""" """********************************************************************************************************************""" """ Delete backup on source_host...start""" if "aws.3top.com" in t_host: my_logger.debug("Found \"aws.3top.com\" in %s" % t_host) my_logger.debug( "Calling delete_backup_on_aws_virtuoso(%s, %s, %s, %s)" % (v_t_backup_subpath, timestamp, t_host, t_user, t_dev_key_file)) try: delete_backup_on_aws_virtuoso(v_t_backup_subpath, timestamp, t_host, t_user, t_dev_key_file) except: my_logger.error( "Calling delete_backup_on_aws_virtuoso() failed. Exiting!") sys.exit( "Calling delete_backup_on_aws_virtuoso() failed. Exiting!") my_logger.debug("Calling delete_backup_on_aws_virtuoso() Successful") elif "nyc.3top.com" in t_host: my_logger.debug("Found \"nyc.3top.com\" in %s" % t_host) my_logger.debug( "Calling delete_backup_on_nyc_virtuoso(%s, %s, %s, %s)" % (v_s_backup_subpath, timestamp, t_host, t_user)) try: delete_backup_on_nyc_virtuoso(v_t_backup_subpath, timestamp, t_host, t_user) except: my_logger.error( "Calling delete_backup_on_nyc_virtuoso() failed. Exiting!") sys.exit( "Calling delete_backup_on_nyc_virtuoso() failed. Exiting!") my_logger.debug("Calling delete_backup_on_nyc_virtuoso() Successful") """ Delete backup on source_host...stop""" """********************************************************************************************************************""" """ Put backup from local to source_host...start""" """Create source_host v_t_temp_dir ...start""" #print dirTimestamp v_t_temp_dir = "/tmp/virtuoso-restore/one_graph/" + timestamp """Create local source backup_before_dir...stop""" if "aws.3top.com" in t_host: my_logger.debug( "Running v_push_backup_to_aws_target(%s, %s, %s, %s) failed. Exiting!" % (t_user, t_host, l_t_backup_before_dir + "/*", t_dev_key_file, v_t_temp_dir)) try: v_push_backup_to_aws_target(t_user, t_host, l_t_backup_before_dir + "/*", t_dev_key_file, v_t_temp_dir) except: my_logger.error("v_push_backup_to_aws_target() failed. Exiting!") sys.exit("v_push_backup_to_aws_target() failed. Exiting!") my_logger.debug("v_push_backup_to_aws_target() Successful") elif "nyc.3top.com" in t_host: my_logger.debug( "Running v_push_backup_to_nyc_target(%s, %s, %s, %s) failed. Exiting!" % (t_user, t_host, l_t_backup_before_dir + "/*", v_t_temp_dir)) try: v_push_backup_to_nyc_target(t_user, t_host, l_t_backup_before_dir + "/*", v_t_temp_dir) except: my_logger.error("v_push_backup_to_nyc_target() failed. Exiting!") sys.exit("v_push_backup_to_nyc_target() failed. Exiting!") my_logger.debug("v_push_backup_to_nyc_target() Successful") """ Put backup from local to source_host...stop""" """********************************************************************************************************************""" """ Put restore backup...start""" for graph in graph_list: my_logger.debug("Starting restore for graph %s in %s" % (graph, t_host)) try: v_restore_rw(t_user, t_host, t_dev_key_file, graph, v_t_temp_dir) except: my_logger.error("Restore failed for graph: %s. Exiting!" % graph) sys.exit("Restore failed for graph: %s. Exiting!" % graph) my_logger.debug("Restore for graph: %s successful!" % graph) """ Put restore backup...stop""" """********************************************************************************************************************""" """ Delete backup on ~/tmp...start""" """ Delete backup on ~/tmp...stop""" """********************************************************************************************************************"""