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
1diff --git a/bootstack-ops/backup.py b/bootstack-ops/backup.py
2index ac85e29..464be31 100755
3--- a/bootstack-ops/backup.py
4+++ b/bootstack-ops/backup.py
5@@ -6,6 +6,7 @@
6 # *) Swift configuration and rings
7 # *) MySQL (various OpenStack services)
8 # *) PostgreSQL (Landscape)
9+# *) PostgreSQL (MaaS db)
10
11 import asyncio
12 from juju.client.connection import JujuData
13@@ -70,6 +71,19 @@ async def swift_backup(path, date):
14 print("Done backing up swift.")
15
16
17+async def maas_db_backup():
18+
19+ #Backup the psql db from this local maas server, need sudo/root to -U postgres
20+ #Needs to have this permission in sudoers - do not give jujumanage full sudo access!
21+ command = "sudo su - postgres -c pg_dumpall -U postgres | gzip > {}/maasdb-{}.gz".format( path, date )
22+
23+ print("Backing up maasdb with{}...").format( command )
24+
25+ await asyncio.create_subprocess_shell(command)
26+
27+ print("maasdb backed up")
28+
29+
30 def main():
31
32 parser = argparse.ArgumentParser(description='Backup key services for BootStack.')
33@@ -87,6 +101,7 @@ def main():
34 loop.run_until_complete(asyncio.gather(
35 juju_backup(args.path, datestamp),
36 juju_client_backup(args.path, datestamp),
37+ maas_db_backup(args.path, datestamp)
38 #swift_backup(args.path, datestamp)
39 ))
40 loop.close()

Subscribers

People subscribed via source and target branches

to all changes: