Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions installation_and_upgrade/ibex_install_utils/install_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,6 @@ def run_instrument_deploy_main(self) -> None:
self._git_tasks.show_git_status()
self._backup_tasks.backup_old_directories()
self._backup_tasks.backup_checker()
self._mysql_tasks.backup_database()
self._mysql_tasks.truncate_database()
self._server_tasks.install_ibex_server()
self._system_tasks.create_virtual_envs()
self._server_tasks.update_icp(self.icp_in_labview_modules())
Expand All @@ -261,11 +259,6 @@ def run_instrument_deploy_pre_stop(self) -> None:
self._system_tasks.user_confirm_upgrade_type_on_machine("Client/Server Machine")
self._server_tasks.save_motor_blocks_blockserver_to_file()

def run_truncate_database(self) -> None:
"""Backup and truncate databases only"""
self._mysql_tasks.backup_database()
self._mysql_tasks.truncate_database()

def run_force_upgrade_mysql(self) -> None:
""":key
Do upgrade of mysql, with data dump.
Expand Down Expand Up @@ -384,10 +377,6 @@ def run_vhd_post_install(self) -> None:
UpgradeInstrument.remove_all_and_install_client_and_server,
"install just the latest clean build of the server, client and genie_python",
),
"truncate_database": (
UpgradeInstrument.run_truncate_database,
"backup and truncate the sql database on the instrument",
),
"update_icp": (
UpgradeInstrument.run_update_icp,
"update isisicp on the instrument",
Expand Down
76 changes: 0 additions & 76 deletions installation_and_upgrade/ibex_install_utils/tasks/mysql_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from typing import Generator

from ibex_install_utils.admin_runner import AdminCommandBuilder
from ibex_install_utils.exceptions import ErrorInRun
from ibex_install_utils.logger import temporarily_disable_logging
from ibex_install_utils.run_process import RunProcess
from ibex_install_utils.software_dependency.mysql import MySQL
Expand Down Expand Up @@ -84,32 +83,6 @@ def _get_mysql_backup_dir(self) -> str:
os.mkdir(mysql_backup_dir)
return mysql_backup_dir

@task("Truncate database")
def truncate_database(self) -> None:
"""
Truncate the message log, sample and alarms tables
"""
try:
mysql_bin_dir = self._get_mysql_dir()

sql_command = (
"truncate table msg_log.message;"
"truncate table archive.sample;truncate table alarm.pv"
)

RunProcess(
MYSQL_FILES_DIR,
"mysql.exe",
executable_directory=mysql_bin_dir,
prog_args=["-u", "root", "-p", "--execute", sql_command],
capture_pipes=False,
).run()

except ErrorInRun as ex:
self.prompt.prompt_and_raise_if_not_yes(
f"Unable to run mysql command, please truncate the database manually. Error is {ex}"
)

def _configure_mysql(self) -> None:
"""
Copy mysql settings and run the MySQL configuration script
Expand Down Expand Up @@ -411,55 +384,6 @@ def configure_mysql_for_vhd_post_install(self) -> None:

sleep(5) # Time for service to start

@task("Backup database")
def backup_database(self) -> None:
"""
Backup the database
"""
mysql_bin_dir = self._get_mysql_dir()
result_file = os.path.join(
self._get_mysql_backup_dir(),
SQLDUMP_FILE_TEMPLATE.format(BaseTasks._today_date_for_filenames()),
)

# Get the number of tables to be backed up
sql_command = "show databases; use information_schema; show tables; SELECT FOUND_ROWS();"
count_tables = RunProcess(
MYSQL_FILES_DIR,
"mysql.exe",
executable_directory=mysql_bin_dir,
prog_args=["-u", "root", "-p", "--execute", sql_command],
capture_pipes=True,
capture_last_output=True,
)
count_tables.run()
tables = (
int(count_tables.captured_output) - 1
) # it seems to end up with an extra table when counting this.

dump_command = [
"-u",
"root",
"-p",
"--all-databases",
"--single-transaction",
"--verbose",
f"--result-file={result_file}",
]
RunProcess(
MYSQL_FILES_DIR,
"mysqldump.exe",
executable_directory=mysql_bin_dir,
prog_args=dump_command,
capture_pipes=True,
progress_metric=[tables, "Retrieving table structure", "Backing up table "],
).run()

if os.path.getsize(result_file) < SMALLEST_PERMISSIBLE_MYSQL_DUMP_FILE_IN_BYTES:
self.prompt.prompt_and_raise_if_not_yes(
f"Dump file '{result_file}' seems to be small is it correct? "
)

def _backup_data(self) -> None:
"""
Backup the data for transfer. This dumps just the data not the schema.
Expand Down
23 changes: 0 additions & 23 deletions installation_and_upgrade/truncate_database.bat

This file was deleted.

Loading