Merge bootstack-ops:rt100872-maasdb-backup into bootstack-ops:master

Proposed by Jill Rouleau
Status: Merged
Approved by: Drew Freiberger
Approved revision: 8610106adae3ed3af853517ed4f0c67c10e978e3
Merged at revision: e639baf7109abe64761d0ea2d753b348e3bf3faf
Proposed branch: bootstack-ops:rt100872-maasdb-backup
Merge into: bootstack-ops:master
Diff against target: 40 lines (+15/-0)
1 file modified
bootstack-ops/backup.py (+15/-0)
Reviewer Review Type Date Requested Status
Drew Freiberger (community) Approve
Review via email: mp+319989@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Peter Sabaini (peter-sabaini) wrote :

I realize that this MP isn't the only code in here sporting async/await constructs. But I still wonder if we should leave out trusty as a platform for our scripts -- as async/await only work in Python3.5+ which is not in the trusty repos?

Revision history for this message
Jill Rouleau (jillrouleau) wrote :

This backup script should only be deployed to new environments, it's replacing the old backup script that didn't work with juju2. So should be ok to depend on py3.5, confirmed w/ csanders on sync call.

Revision history for this message
Drew Freiberger (afreiberger) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/bootstack-ops/backup.py b/bootstack-ops/backup.py
index ac85e29..464be31 100755
--- a/bootstack-ops/backup.py
+++ b/bootstack-ops/backup.py
@@ -6,6 +6,7 @@
6# *) Swift configuration and rings6# *) Swift configuration and rings
7# *) MySQL (various OpenStack services)7# *) MySQL (various OpenStack services)
8# *) PostgreSQL (Landscape)8# *) PostgreSQL (Landscape)
9# *) PostgreSQL (MaaS db)
910
10import asyncio11import asyncio
11from juju.client.connection import JujuData12from juju.client.connection import JujuData
@@ -70,6 +71,19 @@ async def swift_backup(path, date):
70 print("Done backing up swift.")71 print("Done backing up swift.")
7172
7273
74async def maas_db_backup():
75
76 #Backup the psql db from this local maas server, need sudo/root to -U postgres
77 #Needs to have this permission in sudoers - do not give jujumanage full sudo access!
78 command = "sudo su - postgres -c pg_dumpall -U postgres | gzip > {}/maasdb-{}.gz".format( path, date )
79
80 print("Backing up maasdb with{}...").format( command )
81
82 await asyncio.create_subprocess_shell(command)
83
84 print("maasdb backed up")
85
86
73def main():87def main():
7488
75 parser = argparse.ArgumentParser(description='Backup key services for BootStack.')89 parser = argparse.ArgumentParser(description='Backup key services for BootStack.')
@@ -87,6 +101,7 @@ def main():
87 loop.run_until_complete(asyncio.gather(101 loop.run_until_complete(asyncio.gather(
88 juju_backup(args.path, datestamp),102 juju_backup(args.path, datestamp),
89 juju_client_backup(args.path, datestamp),103 juju_client_backup(args.path, datestamp),
104 maas_db_backup(args.path, datestamp)
90 #swift_backup(args.path, datestamp)105 #swift_backup(args.path, datestamp)
91 ))106 ))
92 loop.close()107 loop.close()

Subscribers

People subscribed via source and target branches

to all changes: