Merge bootstack-ops:fix_juju_backups into bootstack-ops:master

Proposed by Craige McWhirter
Status: Merged
Approved by: James Hebden
Approved revision: 26abc1da9ad2cc8f5395f8877c1013d291b23879
Merged at revision: bfa46e236b79517a0e3d2ca2cb0ab3db3e2b5dd4
Proposed branch: bootstack-ops:fix_juju_backups
Merge into: bootstack-ops:master
Diff against target: 52 lines (+16/-4)
1 file modified
bootstack-ops/backup.py (+16/-4)
Reviewer Review Type Date Requested Status
James Hebden (community) Approve
Review via email: mp+336277@code.launchpad.net

Description of the change

Adding the removal of backups from juju itself

This patches added the removal backups from the juju controller itself.

Tested against Juju v2.3.2-xenial-amd64 (charmlab). No support for Juju 1.x as I didn't see any other support for 1.x in the script and assumed it was considered redundant for this script.

Also removed superfluous white spaces (automated via vim).

To post a comment you must log in.
Revision history for this message
James Hebden (ec0) wrote :

LGTM. Also, your assumption around Juju 1.25 support in the new ops bundle is correct. It only supports Juju 2.0+

review: Approve
Revision history for this message
Nikolay Nikolaev (n.nikolaev) :

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 464be31..71753fb 100755
3--- a/bootstack-ops/backup.py
4+++ b/bootstack-ops/backup.py
5@@ -14,7 +14,7 @@ from juju.unit import Unit
6 from juju.model import Model,ModelEntity
7 import os
8 import argparse
9-import datetime
10+import datetime
11 import tarfile
12
13 async def juju_backup( path, date ):
14@@ -38,8 +38,20 @@ async def juju_backup( path, date ):
15 backup_proc = await asyncio.create_subprocess_shell(command)
16 await backup_proc.wait()
17
18+ # Remove the backups from the juju controller itself
19+ remove_command = "for backup in " \
20+ "$(juju list-backups -m {0} | sort | head -n -5); " \
21+ "do juju remove-backup $backup -m {0}; done" \
22+ .format(model)
23+ print(remove_command)
24+
25+ remove_backup_proc = await \
26+ asyncio.create_subprocess_shell(remove_command)
27+ await remove_backup_proc.wait()
28+
29+
30 async def juju_client_backup( path, date ):
31-
32+
33 filename = "{}/juju-client-backup-{}.tar.gz".format( path, date )
34
35 print ("Backing up juju client settings to {}...".format( filename ))
36@@ -48,7 +60,7 @@ async def juju_client_backup( path, date ):
37 tar.add(os.path.expanduser("~/.local/share/juju"))
38
39 print ("Juju client settings backed up.")
40-
41+
42
43 async def swift_backup(path, date):
44
45@@ -66,7 +78,7 @@ async def swift_backup(path, date):
46 print("No swift-proxy/0 unit");
47 return
48
49- await swift_proxy.run("echo hello");
50+ await swift_proxy.run("echo hello");
51
52 print("Done backing up swift.")
53

Subscribers

People subscribed via source and target branches

to all changes: