예제 #1
0
    def final_actions(self):
        # Type Database name of table which you want to restore

        logger.debug("+-" * 40)
        database_name = input("Type Database name: ")

        # Type name of table which you want to restore
        table_name = input("Type Table name: ")

        path = self.get_table_ibd_file(database_name=database_name,
                                       table_name=table_name)
        path_to_mysql_datadir = self.datadir + "/" + database_name

        if path:
            path_to_frm_file = path[:-3] + 'frm'

        obj_check_env = check_env.CheckEnv(self.conf)

        if path:
            if obj_check_env.check_mysql_uptime():
                if self.check_innodb_file_per_table():
                    if self.check_mysql_version():
                        if self.check_database_exists_on_mysql(
                                database_name=database_name):
                            if self.check_table_exists_on_mysql(
                                    path_to_frm_file=path_to_frm_file,
                                    database_name=database_name,
                                    table_name=table_name):
                                if self.lock_table(database_name=database_name,
                                                   table_name=table_name):
                                    if self.alter_tablespace(
                                            database_name=database_name,
                                            table_name=table_name):
                                        if self.copy_ibd_file_back(
                                                path_of_ibd_file=path,
                                                path_to_mysql_database_dir=
                                                path_to_mysql_datadir):
                                            if self.give_chown(
                                                    path_to_mysql_database_dir=
                                                    path_to_mysql_datadir):
                                                if self.import_tablespace(
                                                        database_name=
                                                        database_name,
                                                        table_name=table_name):
                                                    if self.unlock_tables():
                                                        logger.debug("+-" * 40)

                                                        logger.debug(
                                                            "Table Recovered! ..."
                                                            + '-+' * 30)
예제 #2
0
    def final_actions(self):
        # Type Database name of table which you want to restore
        database_name = input("Type Database name: ")
        # Type name of table which you want to restore
        table_name = input("Type Table name: ")
        path = self.get_table_ibd_file(database_name=database_name,
                                       table_name=table_name)
        path_to_mysql_datadir = self.datadir + "/" + database_name

        if path:
            path_to_frm_file = path[:-3] + 'frm'

        obj_check_env = check_env.CheckEnv(self.conf)

        if path:
            try:
                obj_check_env.check_mysql_uptime()
                self.check_innodb_file_per_table()
                self.check_mysql_version()
                self.check_database_exists_on_mysql(
                    database_name=database_name)
                self.check_table_exists_on_mysql(
                    path_to_frm_file=path_to_frm_file,
                    database_name=database_name,
                    table_name=table_name)
                self.lock_table(database_name=database_name,
                                table_name=table_name)
                self.alter_tablespace(database_name=database_name,
                                      table_name=table_name)
                self.copy_ibd_file_back(
                    path_of_ibd_file=path,
                    path_to_mysql_database_dir=path_to_mysql_datadir)
                self.give_chown(
                    path_to_mysql_database_dir=path_to_mysql_datadir)
                self.import_tablespace(database_name=database_name,
                                       table_name=table_name)
                self.unlock_tables()
            except Exception as err:
                logger.error("FAILED: Table is not recovered")
                logger.error(err)
                raise RuntimeError("FAILED: Table is not recovered")
            else:
                logger.info("OK: Table Recovered! ...")
                return True