def neo4j_operations(dict_source_ttSettings, dict_target_ttSettings, s_user, t_user, s_host, t_host): try: log_dir = swapTimeStampDirPath log_dir_split=log_dir.split("/") timestamp= log_dir_split[len(log_dir_split)-1] print "Timestamp: %s"%timestamp backup_path = swapTimeStampDirPath + "/neo4j_backup" if os.path.exists(backup_path): os.makedirs(backup_path) source_suffix = s_host + "-Before" source_dir_backup=log_dir + "/neo4j_backup/" + source_suffix target_suffix = t_host + "-Before" target_dir_backup=log_dir + "/neo4j_backup/" + target_suffix print "\nStarting backup operations for %s@%s"%(s_user,s_host) l_host=raw_input("Enter local hostname: ") l_user= raw_input("Enter username for local host:%s : "%l_host) if "aws.3top.com" in dict_source_ttSettings["Environment_Name"]: tar_source_file=n_backup_aws_to_local(s_user,s_host, l_user, l_host, dict_source_ttSettings["ec2"]["cert_private_key"], source_dir_backup, log_dir) elif "nyc.3top.com" in dict_source_ttSettings["Environment_Name"]: tar_source_file=n_backup_nyc_to_local(s_user,s_host, l_user, l_host, source_dir_backup, log_dir) my_logger.info("Source file (.tar) location: %s"%tar_source_file) print "\nStarting backup operations for %s@%s"%(t_user,t_host) if "aws.3top.com" in dict_target_ttSettings["Environment_Name"]: print "user: %s"%t_user print "host: %s"%t_host print "Dir Backup: %s"%target_dir_backup print"Log Dir: %s"%log_dir tar_target_file=n_backup_aws_to_local(t_user,t_host, l_user, l_host, dict_source_ttSettings["ec2"]["cert_private_key"], target_dir_backup, log_dir) elif "nyc.3top.com" in dict_target_ttSettings["Environment_Name"]: print "user: %s"%t_user print "host: %s"%t_host print "Dir Backup: %s"%target_dir_backup print"Log Dir: %s"%log_dir tar_target_file=n_backup_nyc_to_local(t_user,t_host, l_user, l_host, target_dir_backup, log_dir) my_logger.info("Target file (.tar) location: %s"%tar_target_file) if "nyc.3top.com" in dict_target_ttSettings["Environment_Name"]: print "\nStarting clone operations for %s@%s"%(t_user,t_host) n_clone_nyc_db(t_user,t_host, source_suffix, timestamp, 'NA') elif "aws.3top.com" in dict_target_ttSettings["Environment_Name"]: print "\nStarting clone operations for %s@%s"%(t_user,t_host) n_clone_aws_db(t_user,t_host, dict_target_ttSettings["ec2"]["cert_private_key"], source_suffix, timestamp, 'NA') except: my_logger.error("Encountered failure in Neo4j Operations. Exiting!") sys.exit("Encountered failure in Neo4j Operations. Exiting!") my_logger.debug("Neo4j operations() completed successfully. ")
def neo4j_backup(dict_source_ttSettings, s_user, s_host, backup_dir): try: log_dir = swapTimeStampDirPath log_dir_split=log_dir.split("/") timestamp= log_dir_split[len(log_dir_split)-1] print "Timestamp: %s"%timestamp backup_path = backup_dir if not os.path.exists(backup_path): os.makedirs(backup_path) source_suffix = "backup" source_dir_backup = backup_path print "\nStarting backup operations for %s@%s"%(s_user,s_host) l_host=raw_input("Enter local hostname: ") l_user= raw_input("Enter username for local host: %s: "%l_host) if "aws.3top.com" in dict_source_ttSettings["Environment_Name"]: tar_source_file=n_backup_aws_to_local(s_user,s_host, l_user, l_host, dict_source_ttSettings["ec2"]["cert_private_key"], source_dir_backup, log_dir) elif "nyc.3top.com" in dict_source_ttSettings["Environment_Name"]: tar_source_file=n_backup_nyc_to_local(s_user,s_host, l_user, l_host, source_dir_backup, log_dir) my_logger.info("Source file (.tar) location: %s"%tar_source_file) except: my_logger.error("Encountered failure in Neo4j Backup(). Exiting!") sys.exit("Encountered failure in Neo4j Backup(). Exiting!") my_logger.debug("Neo4j Backup() completed successfully. ")
def neo4j_backup(dict_source_ttSettings, s_user, s_host, backup_dir): try: log_dir = swapTimeStampDirPath log_dir_split = log_dir.split("/") timestamp = log_dir_split[len(log_dir_split) - 1] print "Timestamp: %s" % timestamp backup_path = backup_dir if not os.path.exists(backup_path): os.makedirs(backup_path) source_suffix = "backup" source_dir_backup = backup_path print "\nStarting backup operations for %s@%s" % (s_user, s_host) l_host = raw_input("Enter local hostname: ") l_user = raw_input("Enter username for local host: %s: " % l_host) if "aws.3top.com" in dict_source_ttSettings["Environment_Name"]: tar_source_file = n_backup_aws_to_local( s_user, s_host, l_user, l_host, dict_source_ttSettings["ec2"]["cert_private_key"], source_dir_backup, log_dir) elif "nyc.3top.com" in dict_source_ttSettings["Environment_Name"]: tar_source_file = n_backup_nyc_to_local(s_user, s_host, l_user, l_host, source_dir_backup, log_dir) my_logger.info("Source file (.tar) location: %s" % tar_source_file) except: my_logger.error("Encountered failure in Neo4j Backup(). Exiting!") sys.exit("Encountered failure in Neo4j Backup(). Exiting!") my_logger.debug("Neo4j Backup() completed successfully. ")
def neo4j_operations(dict_source_ttSettings, dict_target_ttSettings, s_user, t_user, s_host, t_host): try: log_dir = swapTimeStampDirPath log_dir_split = log_dir.split("/") timestamp = log_dir_split[len(log_dir_split) - 1] print "Timestamp: %s" % timestamp backup_path = swapTimeStampDirPath + "/neo4j_backup" if os.path.exists(backup_path): os.makedirs(backup_path) source_suffix = s_host + "-Before" source_dir_backup = log_dir + "/neo4j_backup/" + source_suffix target_suffix = t_host + "-Before" target_dir_backup = log_dir + "/neo4j_backup/" + target_suffix print "\nStarting backup operations for %s@%s" % (s_user, s_host) l_host = raw_input("Enter local hostname: ") l_user = raw_input("Enter username for local host:%s : " % l_host) if "aws.3top.com" in dict_source_ttSettings["Environment_Name"]: tar_source_file = n_backup_aws_to_local( s_user, s_host, l_user, l_host, dict_source_ttSettings["ec2"]["cert_private_key"], source_dir_backup, log_dir) elif "nyc.3top.com" in dict_source_ttSettings["Environment_Name"]: tar_source_file = n_backup_nyc_to_local(s_user, s_host, l_user, l_host, source_dir_backup, log_dir) my_logger.info("Source file (.tar) location: %s" % tar_source_file) print "\nStarting backup operations for %s@%s" % (t_user, t_host) if "aws.3top.com" in dict_target_ttSettings["Environment_Name"]: print "user: %s" % t_user print "host: %s" % t_host print "Dir Backup: %s" % target_dir_backup print "Log Dir: %s" % log_dir tar_target_file = n_backup_aws_to_local( t_user, t_host, l_user, l_host, dict_source_ttSettings["ec2"]["cert_private_key"], target_dir_backup, log_dir) elif "nyc.3top.com" in dict_target_ttSettings["Environment_Name"]: print "user: %s" % t_user print "host: %s" % t_host print "Dir Backup: %s" % target_dir_backup print "Log Dir: %s" % log_dir tar_target_file = n_backup_nyc_to_local(t_user, t_host, l_user, l_host, target_dir_backup, log_dir) my_logger.info("Target file (.tar) location: %s" % tar_target_file) if "nyc.3top.com" in dict_target_ttSettings["Environment_Name"]: print "\nStarting clone operations for %s@%s" % (t_user, t_host) n_clone_nyc_db(t_user, t_host, source_suffix, timestamp, 'NA') elif "aws.3top.com" in dict_target_ttSettings["Environment_Name"]: print "\nStarting clone operations for %s@%s" % (t_user, t_host) n_clone_aws_db(t_user, t_host, dict_target_ttSettings["ec2"]["cert_private_key"], source_suffix, timestamp, 'NA') except: my_logger.error("Encountered failure in Neo4j Operations. Exiting!") sys.exit("Encountered failure in Neo4j Operations. Exiting!") my_logger.debug("Neo4j operations() completed successfully. ")