Skip to content

Commit

Permalink
Add document how to find mysql backup file and print path in output (#…
Browse files Browse the repository at this point in the history
…589)

* docs: Add document how to find mysql backup file

* refactor: Change logger.info to spinner.info

* docs: Merge how to backup documents

* docs: Use backquotes for code samples

* docs: Add comment to explain how info() works

* docs: Change comment wording

* docs: Change wording
  • Loading branch information
jneo8 authored Oct 23, 2024
1 parent 44f5a5a commit cdd59a8
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 8 deletions.
13 changes: 11 additions & 2 deletions cou/steps/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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__)
Expand All @@ -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
Expand Down
22 changes: 17 additions & 5 deletions docs/how-to/no-backup.rst → docs/how-to/backup.rst
Original file line number Diff line number Diff line change
@@ -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:

Expand Down
2 changes: 1 addition & 1 deletion docs/how-to/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit cdd59a8

Please sign in to comment.