add automated Apps Backup option

This commit is contained in:
kjeld Schouten-Lebbing 2022-01-19 21:00:14 +01:00
parent 2c1c0a7a79
commit 7f8f523fca
No known key found for this signature in database
GPG Key ID: 4CDAD4A532BC1EDB
3 changed files with 24 additions and 3 deletions

View File

@ -17,9 +17,12 @@ Just run `trueupdate` in the shell of your TrueNAS SCALE machine, to have it pro
Additional options are available:
- `trueupdate --catalog CATALOGNAME` where CATALOGNAME is the name of the catalog you want to process in caps
- `trueupdate --versioning SCHEME` where SCHEME is the highest semver version you want to process. options: `patch`, `minor` and `major`
- `trueupdate -h` for the CLI help page
- `trueupdate -s` or ` trueupdate --sync` to sync the catalogs before running auto-update
- `trueupdate -p` or ` trueupdate --prune` to prune (remove) old docker images after running auto-update
- `trueupdate -a` or ` trueupdate --all` updates both active (running) and non-active (stuck or stopped) Apps
- `trueupdate --catalog CATALOGNAME` where CATALOGNAME is the name of the catalog you want to process in caps
- `trueupdate --versioning SCHEME` where SCHEME is the highest semver version you want to process. options: `patch`, `minor` and `major`
- `trueupdate -b` or ` trueupdate --backup` backup the complete Apps system prior to updates

View File

@ -7,7 +7,7 @@ README_MD = open(join(dirname(abspath(__file__)), "README.md")).read()
setup(
name="trueupdate",
version="2.2.0",
version="2.3.0",
# The packages that constitute your project.
# For my project, I have only one - "pydash".

View File

@ -89,12 +89,14 @@ def process_args():
global SYNC
global PRUNE
global ALL
global BACKUP
parser = argparse.ArgumentParser(description='Update TrueNAS SCALE Apps')
parser.add_argument('--catalog', nargs='?', default='ALL', help='name of the catalog you want to process in caps. Or "ALL" to render all catalogs.')
parser.add_argument('--versioning', nargs='?', default='minor', help='Name of the versioning scheme you want to update. Options: major, minor or patch. Defaults to minor')
parser.add_argument('-s', '--sync', action="store_true", help='sync catalogs before trying to update')
parser.add_argument('-p', '--prune', action="store_true", help='prune old docker images after update')
parser.add_argument('-a', '--all', action="store_true", help='update "active" apps only and ignore "stopped" or "stuck" apps')
parser.add_argument('-b', '--backup', action="store_true", help='backup the complete Apps system prior to updates')
args = parser.parse_args()
CATALOG = args.catalog
VERSIONING = args.versioning
@ -110,6 +112,10 @@ def process_args():
ALL = True
else:
ALL = False
if args.backup:
BACKUP = True
else:
BACKUP = False
def sync_catalog():
if SYNC:
@ -128,9 +134,21 @@ def docker_prune():
process = subprocess.Popen(["docker", "image", "prune", "-af"], stdout=subprocess.PIPE)
print("Images pruned.\n")
def chart_backup():
if BACKUP:
print("Running App Backup...\n")
process = subprocess.Popen(["cli", "-c", "app kubernetes backup_chart_releases"], stdout=subprocess.PIPE)
while process.poll() is None:
lines = process.stdout.readline()
print (lines.decode('utf-8'))
temp = process.stdout.read()
if temp:
print (temp.decode('utf-8'))
def run():
process_args()
print("Starting TrueCharts App updater...\n")
chart_backup()
sync_catalog()
charts = fetch_charts()
parse_charts(charts)