From 4512ec484a2643c4cea3af42e02f3ee1fbd44b26 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Wed, 25 Dec 2024 11:04:39 +0530 Subject: [PATCH 1/4] feat(easy-install): backup cron --- easy-install.py | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/easy-install.py b/easy-install.py index 3a61b277..b45cceb5 100755 --- a/easy-install.py +++ b/easy-install.py @@ -78,6 +78,7 @@ def write_to_env( db_pass: str, admin_pass: str, email: str, + cronstring: str, erpnext_version: str = None, http_port: str = None, ) -> None: @@ -97,6 +98,7 @@ def write_to_env( f"SITE_ADMIN_PASS={admin_pass}\n", f"SITES={quoted_sites}\n", "PULL_POLICY=missing\n", + f'BACKUP_CRONSTRING="{cronstring}"', ] if http_port: @@ -125,6 +127,7 @@ def start_prod( project: str, sites: List[str] = [], email: str = None, + cronstring: str = None, version: str = None, image: str = None, is_https: bool = True, @@ -156,6 +159,7 @@ def start_prod( db_pass=db_pass, admin_pass=admin_pass, email=email, + cronstring=cronstring, erpnext_version=version, http_port=http_port if not is_https and http_port else None, ) @@ -180,6 +184,7 @@ def start_prod( db_pass=db_pass, admin_pass=admin_pass, email=email, + cronstring=cronstring, erpnext_version=version, http_port=http_port if not is_https and http_port else None, ) @@ -202,6 +207,8 @@ def start_prod( if is_https else "overrides/compose.noproxy.yaml" ), + "-f", + "overrides/compose.backup-cron.yaml", "--env-file", ".env", "config", @@ -258,6 +265,7 @@ def setup_prod( project: str, sites: List[str], email: str, + cronstring: str, version: str = None, image: str = None, apps: List[str] = [], @@ -271,6 +279,7 @@ def setup_prod( project=project, sites=sites, email=email, + cronstring=cronstring, version=version, image=image, is_https=is_https, @@ -298,7 +307,8 @@ def setup_prod( def update_prod( project: str, version: str = None, - image=None, + image: str = None, + cronstring: str = None, is_https: bool = False, http_port: str = None, ) -> None: @@ -306,6 +316,7 @@ def update_prod( project=project, version=version, image=image, + cronstring=cronstring, is_https=is_https, http_port=http_port, ) @@ -516,11 +527,12 @@ def add_setup_options(parser: argparse.ArgumentParser): def add_common_parser(parser: argparse.ArgumentParser): parser = add_project_option(parser) + parser.add_argument("-g", "--cronstring", help="Cronstring", default="@every 6h") parser.add_argument("-i", "--image", help="Full Image Name") - parser.add_argument("-q", "--no-ssl", action="store_true", help="No https") parser.add_argument( "-m", "--http-port", help="Http port in case of no-ssl", default="8080" ) + parser.add_argument("-q", "--no-ssl", action="store_true", help="No https") parser.add_argument( "-v", "--version", @@ -567,8 +579,8 @@ def add_build_parser(subparsers: argparse.ArgumentParser): parser.add_argument( "-c", "--containerfile", - help="Path to Containerfile: images/layered/Containerfile", - default="images/layered/Containerfile", + help="Path to Containerfile: images/custom/Containerfile", + default="images/custom/Containerfile", ) parser.add_argument( "-y", @@ -750,7 +762,7 @@ if __name__ == "__main__": elif args.subcommand == "deploy": cprint("\nSetting Up Production Instance\n", level=2) logging.info("Running Production Setup") - if "example.com" in args.email: + if args.email and "example.com" in args.email: cprint("Emails with example.com not acceptable", level=1) sys.exit(1) setup_prod( @@ -758,6 +770,7 @@ if __name__ == "__main__": sites=args.sites, email=args.email, version=args.version, + cronstring=args.cronstring, image=args.image, apps=args.apps, is_https=not args.no_ssl, @@ -775,6 +788,7 @@ if __name__ == "__main__": version=args.version, image=args.image, is_https=not args.no_ssl, + cronstring=args.cronstring, http_port=args.http_port, ) elif args.subcommand == "exec": From 1e0c01750bbcc10a0739de4fd00fe736e3bdde50 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Wed, 25 Dec 2024 11:30:29 +0530 Subject: [PATCH 2/4] fix: backup cronstring params --- easy-install.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/easy-install.py b/easy-install.py index b45cceb5..57f6231c 100755 --- a/easy-install.py +++ b/easy-install.py @@ -744,6 +744,7 @@ if __name__ == "__main__": project=args.project, sites=args.sites, email=args.email, + cronstring=args.cronstring, version=args.version, image=args.image, apps=args.apps, @@ -755,6 +756,7 @@ if __name__ == "__main__": project=args.project, version=args.version, image=args.image, + cronstring=args.cronstring, is_https=not args.no_ssl, http_port=args.http_port, ) From 0ee2eea8201d5c9d41b7f80e7d1499415e40650d Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Wed, 25 Dec 2024 12:22:09 +0530 Subject: [PATCH 3/4] docs(easy-install): update README --- README.md | 6 ++++++ easy-install.py | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 32dd1edc..c9444c65 100755 --- a/README.md +++ b/README.md @@ -97,6 +97,8 @@ options: -h, --help show this help message and exit -n PROJECT, --project PROJECT Project Name + -g, --cronstring CRONSTRING + Backup Cronstring, default: "@every 6h" -i IMAGE, --image IMAGE Full Image Name -q, --no-ssl No https @@ -138,6 +140,8 @@ options: -h, --help show this help message and exit -n PROJECT, --project PROJECT Project Name + -g, --cronstring CRONSTRING + Backup Cronstring, default: "@every 6h" -i IMAGE, --image IMAGE Full Image Name -q, --no-ssl No https @@ -163,6 +167,8 @@ options: -h, --help show this help message and exit -n PROJECT, --project PROJECT Project Name + -g, --cronstring CRONSTRING + Backup Cronstring, default: "@every 6h" -i IMAGE, --image IMAGE Full Image Name -q, --no-ssl No https diff --git a/easy-install.py b/easy-install.py index 57f6231c..7f9e50bf 100755 --- a/easy-install.py +++ b/easy-install.py @@ -527,7 +527,12 @@ def add_setup_options(parser: argparse.ArgumentParser): def add_common_parser(parser: argparse.ArgumentParser): parser = add_project_option(parser) - parser.add_argument("-g", "--cronstring", help="Cronstring", default="@every 6h") + parser.add_argument( + "-g", + "--cronstring", + help='Backup Cronstring, default: "@every 6h"', + default="@every 6h", + ) parser.add_argument("-i", "--image", help="Full Image Name") parser.add_argument( "-m", "--http-port", help="Http port in case of no-ssl", default="8080" From 91e4f7e3bfc8770355001bd7701635191a456693 Mon Sep 17 00:00:00 2001 From: Revant Nandgaonkar Date: Thu, 26 Dec 2024 11:45:07 +0530 Subject: [PATCH 4/4] fix(easy-install): rename --cronstring to --backup-schedule --- README.md | 12 ++++++------ easy-install.py | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index c9444c65..90645f8b 100755 --- a/README.md +++ b/README.md @@ -97,8 +97,8 @@ options: -h, --help show this help message and exit -n PROJECT, --project PROJECT Project Name - -g, --cronstring CRONSTRING - Backup Cronstring, default: "@every 6h" + -g, --backup-schedule BACKUP_SCHEDULE + Backup schedule cronstring, default: "@every 6h" -i IMAGE, --image IMAGE Full Image Name -q, --no-ssl No https @@ -140,8 +140,8 @@ options: -h, --help show this help message and exit -n PROJECT, --project PROJECT Project Name - -g, --cronstring CRONSTRING - Backup Cronstring, default: "@every 6h" + -g, --backup-schedule BACKUP_SCHEDULE + Backup schedule cronstring, default: "@every 6h" -i IMAGE, --image IMAGE Full Image Name -q, --no-ssl No https @@ -167,8 +167,8 @@ options: -h, --help show this help message and exit -n PROJECT, --project PROJECT Project Name - -g, --cronstring CRONSTRING - Backup Cronstring, default: "@every 6h" + -g, --backup-schedule BACKUP_SCHEDULE + Backup schedule cronstring, default: "@every 6h" -i IMAGE, --image IMAGE Full Image Name -q, --no-ssl No https diff --git a/easy-install.py b/easy-install.py index 7f9e50bf..3cb6183e 100755 --- a/easy-install.py +++ b/easy-install.py @@ -529,8 +529,8 @@ def add_common_parser(parser: argparse.ArgumentParser): parser = add_project_option(parser) parser.add_argument( "-g", - "--cronstring", - help='Backup Cronstring, default: "@every 6h"', + "--backup-schedule", + help='Backup schedule cronstring, default: "@every 6h"', default="@every 6h", ) parser.add_argument("-i", "--image", help="Full Image Name") @@ -749,7 +749,7 @@ if __name__ == "__main__": project=args.project, sites=args.sites, email=args.email, - cronstring=args.cronstring, + cronstring=args.backup_schedule, version=args.version, image=args.image, apps=args.apps, @@ -761,7 +761,7 @@ if __name__ == "__main__": project=args.project, version=args.version, image=args.image, - cronstring=args.cronstring, + cronstring=args.backup_schedule, is_https=not args.no_ssl, http_port=args.http_port, ) @@ -777,7 +777,7 @@ if __name__ == "__main__": sites=args.sites, email=args.email, version=args.version, - cronstring=args.cronstring, + cronstring=args.backup_schedule, image=args.image, apps=args.apps, is_https=not args.no_ssl, @@ -795,7 +795,7 @@ if __name__ == "__main__": version=args.version, image=args.image, is_https=not args.no_ssl, - cronstring=args.cronstring, + cronstring=args.backup_schedule, http_port=args.http_port, ) elif args.subcommand == "exec":