diff --git a/cou/steps/backup.py b/cou/steps/backup.py index f27171b4..651f9675 100644 --- a/cou/steps/backup.py +++ b/cou/steps/backup.py @@ -18,7 +18,7 @@ from pathlib import Path from cou.exceptions import UnitNotFound -from cou.utils import COU_DATA +from cou.utils import COU_DATA, progress_indicator from cou.utils.juju_utils import Model logger = logging.getLogger(__name__) @@ -44,9 +44,18 @@ async def backup(model: Model) -> Path: await model.run_on_unit(unit_name, f"chmod o+rx {basedir}") local_file = COU_DATA / os.path.basename(remote_file) - logger.info("SCP from mysql-innodb-cluster:%s to %s ...", remote_file, local_file) + logger.info("SCP from mysql-innodb-cluster:%s to %s ...", remote_file, local_file) await model.scp_from_unit(unit_name, remote_file, str(local_file)) + # Note: a spinner is already running when this function is called, + # so to cleanly print text, we can use .info(), then restart the spinner. + # Not using `print` directly, because that will cause corrupted output + # while the spinner is running. + # info() stop the current spinner and print the text with symbol ℹ. + progress_indicator.info(f"Backed up MySQL to {local_file}") + # Restart the spinner with previous text + progress_indicator.start() + logger.info("Remove permissions to read mysql-innodb-cluster:%s ...", basedir) await model.run_on_unit(unit_name, f"chmod o-rx {basedir}") return local_file diff --git a/docs/how-to/no-backup.rst b/docs/how-to/backup.rst similarity index 84% rename from docs/how-to/no-backup.rst rename to docs/how-to/backup.rst index 968b4c50..3cf67117 100644 --- a/docs/how-to/no-backup.rst +++ b/docs/how-to/backup.rst @@ -1,12 +1,24 @@ -========================================== -Plan/Upgrade without cloud database backup -========================================== +=============== +Backup database +=============== By default, **COU** plans for and runs a backup step of the cloud database before -proceeding to actual upgrade steps. This can be turned off with `--no-backup` flag. +proceeding to actual upgrade steps. + +Find mysql backup file +~~~~~~~~~~~~~~~~~~~~~~ + +The file is store under ``$COU_DATA``, which is ``/home/$USER/.local/share/cou`` if ``$USER`` exists else current directory. + + +Plan/Upgrade without cloud database backup +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +To plan/upgrade without backup, this can be turned off with ``--no-backup`` flag. Usage examples --------------- +^^^^^^^^^^^^^^ + Plan: diff --git a/docs/how-to/index.rst b/docs/how-to/index.rst index 78313eb2..68cf0c1d 100644 --- a/docs/how-to/index.rst +++ b/docs/how-to/index.rst @@ -14,10 +14,10 @@ are possible with **COU**. different-model interruption configure-connection - no-backup skip-upgrading-applications archive-old-data verbosity purge-data-on-shadow-table test-on-juju-openstack-provider watch-cou-logs + backup