Esempio n. 1
0
    def __init__(self, host, dir_to_verify, logger):
        self._host = host
        self._verify_directory = dir_to_verify

        self._log_helper = logger
        config_helper = Config_helper(host=self._host)

        self._ssh_user = config_helper.get_ssh_user()

        self._backup_directory = os.path.join(config_helper.get_backup_dir(), self._host)
Esempio n. 2
0
    def __init__(self, host, dir_to_verify, logger):
        self._host = host
        self._verify_directory = dir_to_verify

        self._log_helper = logger
        config_helper = Config_helper(host=self._host)

        self._ssh_user = config_helper.get_ssh_user()

        self._backup_directory = os.path.join(config_helper.get_backup_dir(),
                                              self._host)
Esempio n. 3
0
    def run(self):
        host = self.queue.get()
        config_helper = Config_helper(host=host)
        backup_root = os.path.join(config_helper.get_backup_dir(), host)
        prepare_dir = os.path.join(backup_root, "prepare")
	archive_dir = os.path.join(backup_root, "ready")

	prepare_error_dir = os.path.join(backup_root, "prepare_error")
	if os.path.isdir(prepare_error_dir):
	    shutil.rmtree(prepare_error_dir)
	verify_error_dir = os.path.join(backup_root, "verify_error")
	if os.path.isdir(verify_error_dir):
            shutil.rmtree(verify_error_dir)

	logger = self.setup_logger(host=host)

	start_time = datetime.now()
	logger.info_message("######### STARTING BACKUP PROCESS #########")

        return_val = self.do_backup(host=host, logger=logger)
        if return_val:
            prepare_status = self.prepare_backup(host=host,
                                    backup_type=return_val['backup_type'],
                                    backup_dir=return_val['backup_dir'],
                                    prepare_dir=prepare_dir,
				    logger=logger)

            if prepare_status:
                verify_status = self.verify_backup(host=host, 
                                        dir_to_verify=prepare_dir,
					logger=logger)
		    
		if verify_status:
		    self.archive_backup(archive_dir=archive_dir,
				    backup_dir=return_val['backup_dir'],
				    dir_to_archive=prepare_dir,
				    logger=logger)

		    self.recycle_backups(host=host, logger=logger)
		else:
		    shutil.move(prepare_dir, verify_error_dir)
	    else:
		shutil.move(prepare_dir, prepare_error_dir)

	end_time = datetime.now()
	timedelta = end_time - start_time
	logger.info_message("######### BACKUP PROCESS COMPLETED "
				"[TOTAL DURATION: %s] #########" % 
				str(timedelta))

        self.queue.task_done()
Esempio n. 4
0
    def run(self):
        host = self.queue.get()
        config_helper = Config_helper(host=host)
        backup_root = os.path.join(config_helper.get_backup_dir(), host)
        prepare_dir = os.path.join(backup_root, "prepare")
        archive_dir = os.path.join(backup_root, "ready")

        prepare_error_dir = os.path.join(backup_root, "prepare_error")
        if os.path.isdir(prepare_error_dir):
            shutil.rmtree(prepare_error_dir)
        verify_error_dir = os.path.join(backup_root, "verify_error")
        if os.path.isdir(verify_error_dir):
            shutil.rmtree(verify_error_dir)

        logger = self.setup_logger(host=host)

        start_time = datetime.now()
        logger.info_message("######### STARTING BACKUP PROCESS #########")

        return_val = self.do_backup(host=host, logger=logger)
        if return_val:
            prepare_status = self.prepare_backup(
                host=host,
                backup_type=return_val['backup_type'],
                backup_dir=return_val['backup_dir'],
                prepare_dir=prepare_dir,
                logger=logger)

            if prepare_status:
                verify_status = self.verify_backup(host=host,
                                                   dir_to_verify=prepare_dir,
                                                   logger=logger)

                if verify_status:
                    self.archive_backup(archive_dir=archive_dir,
                                        backup_dir=return_val['backup_dir'],
                                        dir_to_archive=prepare_dir,
                                        logger=logger)

                    self.recycle_backups(host=host, logger=logger)
                else:
                    shutil.move(prepare_dir, verify_error_dir)
            else:
                shutil.move(prepare_dir, prepare_error_dir)

        end_time = datetime.now()
        timedelta = end_time - start_time
        logger.info_message("######### BACKUP PROCESS COMPLETED "
                            "[TOTAL DURATION: %s] #########" % str(timedelta))

        self.queue.task_done()
Esempio n. 5
0
    def __init__(self, host, logger):
        self._host = host
	self._log_helper = logger

        config_helper = Config_helper(host=self._host)

        self._backup_manager_host = config_helper.get_backup_manager_host()
        self._full_backup_day = config_helper.get_full_backup_day()

        self._remote_backup_cmd = config_helper.get_remote_backup_cmd()

        self._backup_directory = config_helper.get_backup_dir()
        self._backup_full_directory = os.path.join(self._backup_directory, "full")
        self._backup_incremental_directory = os.path.join(self._backup_directory, "incremental")
Esempio n. 6
0
    def __init__(self, host, logger):
	self._host = host
	self._log_helper = logger

	config_helper = Config_helper(host=self._host)
	self._retention_days = int(config_helper.get_retention_days())
	self._retain_ready_backups = int(config_helper.get_retain_num_ready_backups())

	self._threshold_date = datetime.now() - timedelta(days=self._retention_days)

	self._backup_dir = os.path.join(config_helper.get_backup_dir(), self._host)
        self._backup_full_dir = os.path.join(self._backup_dir, "full")
        self._backup_inc_dir = os.path.join(self._backup_dir, "incremental")
	self._archive_dir = os.path.join(self._backup_dir, "ready")
Esempio n. 7
0
    def __init__(self, host, backup_type, backup_dir, prepare_dir, logger):
        self._host = host
        self._backup_type = backup_type
        self._backup_dir = backup_dir
        self._prepare_directory = prepare_dir
        self._log_helper = logger

        config_helper = Config_helper(host=self._host)

        self._backup_directory = config_helper.get_backup_dir()
        self._backup_full_directory = os.path.join(
                                    self._backup_directory, 
                                    "full")
        self._backup_incremental_directory = os.path.join(
                                        self._backup_directory, 
                                        "incremental")
Esempio n. 8
0
    def __init__(self, host, logger):
        self._host = host
        self._log_helper = logger

        config_helper = Config_helper(host=self._host)
        self._retention_days = int(config_helper.get_retention_days())
        self._retain_ready_backups = int(
            config_helper.get_retain_num_ready_backups())

        self._threshold_date = datetime.now() - timedelta(
            days=self._retention_days)

        self._backup_dir = os.path.join(config_helper.get_backup_dir(),
                                        self._host)
        self._backup_full_dir = os.path.join(self._backup_dir, "full")
        self._backup_inc_dir = os.path.join(self._backup_dir, "incremental")
        self._archive_dir = os.path.join(self._backup_dir, "ready")
Esempio n. 9
0
    def __init__(self, host, backup_type, backup_dir, prepare_dir, logger):
        self._host = host
        self._backup_type = backup_type
        self._backup_dir = backup_dir
        self._prepare_directory = prepare_dir
        self._log_helper = logger

        config_helper = Config_helper(host=self._host)

        self._backup_directory = os.path.join(
                                    config_helper.get_backup_dir(), 
                                    self._host)
        self._backup_full_directory = os.path.join(
                                    self._backup_directory, 
                                    "full")
        self._backup_incremental_directory = os.path.join(
                                        self._backup_directory, 
                                        "incremental")
Esempio n. 10
0
    def __init__(self, host, logger):
        self._host = host
        self._log_helper = logger

        config_helper = Config_helper(host=self._host)

        self._backup_manager_host = config_helper.get_backup_manager_host()
        self._full_backup_day = config_helper.get_full_backup_day()

        self._remote_backup_cmd = config_helper.get_remote_backup_cmd()
        self._remote_cmd = Async_remote_command(
            host=self._host, command=self._remote_backup_cmd)

        self._backup_directory = os.path.join(config_helper.get_backup_dir(),
                                              self._host)
        self._backup_full_directory = os.path.join(self._backup_directory,
                                                   "full")
        self._backup_incremental_directory = os.path.join(
            self._backup_directory, "incremental")