Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(easy-install): backup cron #1609

Merged
merged 4 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ options:
-h, --help show this help message and exit
-n PROJECT, --project PROJECT
Project Name
-g, --backup-schedule BACKUP_SCHEDULE
Backup schedule cronstring, default: "@every 6h"
-i IMAGE, --image IMAGE
Full Image Name
-q, --no-ssl No https
Expand Down Expand Up @@ -138,6 +140,8 @@ options:
-h, --help show this help message and exit
-n PROJECT, --project PROJECT
Project Name
-g, --backup-schedule BACKUP_SCHEDULE
Backup schedule cronstring, default: "@every 6h"
-i IMAGE, --image IMAGE
Full Image Name
-q, --no-ssl No https
Expand All @@ -163,6 +167,8 @@ options:
-h, --help show this help message and exit
-n PROJECT, --project PROJECT
Project Name
-g, --backup-schedule BACKUP_SCHEDULE
Backup schedule cronstring, default: "@every 6h"
-i IMAGE, --image IMAGE
Full Image Name
-q, --no-ssl No https
Expand Down
31 changes: 26 additions & 5 deletions easy-install.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
)
Expand All @@ -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,
)
Expand All @@ -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",
Expand Down Expand Up @@ -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] = [],
Expand All @@ -271,6 +279,7 @@ def setup_prod(
project=project,
sites=sites,
email=email,
cronstring=cronstring,
version=version,
image=image,
is_https=is_https,
Expand Down Expand Up @@ -298,14 +307,16 @@ 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:
start_prod(
project=project,
version=version,
image=image,
cronstring=cronstring,
is_https=is_https,
http_port=http_port,
)
Expand Down Expand Up @@ -516,11 +527,17 @@ def add_setup_options(parser: argparse.ArgumentParser):

def add_common_parser(parser: argparse.ArgumentParser):
parser = add_project_option(parser)
parser.add_argument(
"-g",
"--backup-schedule",
help='Backup schedule cronstring, default: "@every 6h"',
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",
Expand Down Expand Up @@ -567,8 +584,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",
Expand Down Expand Up @@ -732,6 +749,7 @@ def get_args_parser():
project=args.project,
sites=args.sites,
email=args.email,
cronstring=args.backup_schedule,
version=args.version,
image=args.image,
apps=args.apps,
Expand All @@ -743,21 +761,23 @@ def get_args_parser():
project=args.project,
version=args.version,
image=args.image,
cronstring=args.backup_schedule,
is_https=not args.no_ssl,
http_port=args.http_port,
)

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(
project=args.project,
sites=args.sites,
email=args.email,
version=args.version,
cronstring=args.backup_schedule,
image=args.image,
apps=args.apps,
is_https=not args.no_ssl,
Expand All @@ -775,6 +795,7 @@ def get_args_parser():
version=args.version,
image=args.image,
is_https=not args.no_ssl,
cronstring=args.backup_schedule,
http_port=args.http_port,
)
elif args.subcommand == "exec":
Expand Down
Loading