2
0
mirror of https://github.com/frappe/bench.git synced 2025-01-04 22:55:25 +00:00

Merge pull request #1609 from revant/easy-install-cron

feat(easy-install): backup cron
This commit is contained in:
Md Hussain Nagaria 2024-12-26 12:47:30 +05:30 committed by GitHub
commit ce7de4f9d1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 32 additions and 5 deletions

View File

@ -97,6 +97,8 @@ options:
-h, --help show this help message and exit -h, --help show this help message and exit
-n PROJECT, --project PROJECT -n PROJECT, --project PROJECT
Project Name Project Name
-g, --backup-schedule BACKUP_SCHEDULE
Backup schedule cronstring, default: "@every 6h"
-i IMAGE, --image IMAGE -i IMAGE, --image IMAGE
Full Image Name Full Image Name
-q, --no-ssl No https -q, --no-ssl No https
@ -138,6 +140,8 @@ options:
-h, --help show this help message and exit -h, --help show this help message and exit
-n PROJECT, --project PROJECT -n PROJECT, --project PROJECT
Project Name Project Name
-g, --backup-schedule BACKUP_SCHEDULE
Backup schedule cronstring, default: "@every 6h"
-i IMAGE, --image IMAGE -i IMAGE, --image IMAGE
Full Image Name Full Image Name
-q, --no-ssl No https -q, --no-ssl No https
@ -163,6 +167,8 @@ options:
-h, --help show this help message and exit -h, --help show this help message and exit
-n PROJECT, --project PROJECT -n PROJECT, --project PROJECT
Project Name Project Name
-g, --backup-schedule BACKUP_SCHEDULE
Backup schedule cronstring, default: "@every 6h"
-i IMAGE, --image IMAGE -i IMAGE, --image IMAGE
Full Image Name Full Image Name
-q, --no-ssl No https -q, --no-ssl No https

View File

@ -78,6 +78,7 @@ def write_to_env(
db_pass: str, db_pass: str,
admin_pass: str, admin_pass: str,
email: str, email: str,
cronstring: str,
erpnext_version: str = None, erpnext_version: str = None,
http_port: str = None, http_port: str = None,
) -> None: ) -> None:
@ -97,6 +98,7 @@ def write_to_env(
f"SITE_ADMIN_PASS={admin_pass}\n", f"SITE_ADMIN_PASS={admin_pass}\n",
f"SITES={quoted_sites}\n", f"SITES={quoted_sites}\n",
"PULL_POLICY=missing\n", "PULL_POLICY=missing\n",
f'BACKUP_CRONSTRING="{cronstring}"',
] ]
if http_port: if http_port:
@ -125,6 +127,7 @@ def start_prod(
project: str, project: str,
sites: List[str] = [], sites: List[str] = [],
email: str = None, email: str = None,
cronstring: str = None,
version: str = None, version: str = None,
image: str = None, image: str = None,
is_https: bool = True, is_https: bool = True,
@ -156,6 +159,7 @@ def start_prod(
db_pass=db_pass, db_pass=db_pass,
admin_pass=admin_pass, admin_pass=admin_pass,
email=email, email=email,
cronstring=cronstring,
erpnext_version=version, erpnext_version=version,
http_port=http_port if not is_https and http_port else None, http_port=http_port if not is_https and http_port else None,
) )
@ -180,6 +184,7 @@ def start_prod(
db_pass=db_pass, db_pass=db_pass,
admin_pass=admin_pass, admin_pass=admin_pass,
email=email, email=email,
cronstring=cronstring,
erpnext_version=version, erpnext_version=version,
http_port=http_port if not is_https and http_port else None, http_port=http_port if not is_https and http_port else None,
) )
@ -202,6 +207,8 @@ def start_prod(
if is_https if is_https
else "overrides/compose.noproxy.yaml" else "overrides/compose.noproxy.yaml"
), ),
"-f",
"overrides/compose.backup-cron.yaml",
"--env-file", "--env-file",
".env", ".env",
"config", "config",
@ -258,6 +265,7 @@ def setup_prod(
project: str, project: str,
sites: List[str], sites: List[str],
email: str, email: str,
cronstring: str,
version: str = None, version: str = None,
image: str = None, image: str = None,
apps: List[str] = [], apps: List[str] = [],
@ -271,6 +279,7 @@ def setup_prod(
project=project, project=project,
sites=sites, sites=sites,
email=email, email=email,
cronstring=cronstring,
version=version, version=version,
image=image, image=image,
is_https=is_https, is_https=is_https,
@ -298,7 +307,8 @@ def setup_prod(
def update_prod( def update_prod(
project: str, project: str,
version: str = None, version: str = None,
image=None, image: str = None,
cronstring: str = None,
is_https: bool = False, is_https: bool = False,
http_port: str = None, http_port: str = None,
) -> None: ) -> None:
@ -306,6 +316,7 @@ def update_prod(
project=project, project=project,
version=version, version=version,
image=image, image=image,
cronstring=cronstring,
is_https=is_https, is_https=is_https,
http_port=http_port, http_port=http_port,
) )
@ -516,11 +527,17 @@ def add_setup_options(parser: argparse.ArgumentParser):
def add_common_parser(parser: argparse.ArgumentParser): def add_common_parser(parser: argparse.ArgumentParser):
parser = add_project_option(parser) 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("-i", "--image", help="Full Image Name")
parser.add_argument("-q", "--no-ssl", action="store_true", help="No https")
parser.add_argument( parser.add_argument(
"-m", "--http-port", help="Http port in case of no-ssl", default="8080" "-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( parser.add_argument(
"-v", "-v",
"--version", "--version",
@ -567,8 +584,8 @@ def add_build_parser(subparsers: argparse.ArgumentParser):
parser.add_argument( parser.add_argument(
"-c", "-c",
"--containerfile", "--containerfile",
help="Path to Containerfile: images/layered/Containerfile", help="Path to Containerfile: images/custom/Containerfile",
default="images/layered/Containerfile", default="images/custom/Containerfile",
) )
parser.add_argument( parser.add_argument(
"-y", "-y",
@ -732,6 +749,7 @@ if __name__ == "__main__":
project=args.project, project=args.project,
sites=args.sites, sites=args.sites,
email=args.email, email=args.email,
cronstring=args.backup_schedule,
version=args.version, version=args.version,
image=args.image, image=args.image,
apps=args.apps, apps=args.apps,
@ -743,6 +761,7 @@ if __name__ == "__main__":
project=args.project, project=args.project,
version=args.version, version=args.version,
image=args.image, image=args.image,
cronstring=args.backup_schedule,
is_https=not args.no_ssl, is_https=not args.no_ssl,
http_port=args.http_port, http_port=args.http_port,
) )
@ -750,7 +769,7 @@ if __name__ == "__main__":
elif args.subcommand == "deploy": elif args.subcommand == "deploy":
cprint("\nSetting Up Production Instance\n", level=2) cprint("\nSetting Up Production Instance\n", level=2)
logging.info("Running Production Setup") 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) cprint("Emails with example.com not acceptable", level=1)
sys.exit(1) sys.exit(1)
setup_prod( setup_prod(
@ -758,6 +777,7 @@ if __name__ == "__main__":
sites=args.sites, sites=args.sites,
email=args.email, email=args.email,
version=args.version, version=args.version,
cronstring=args.backup_schedule,
image=args.image, image=args.image,
apps=args.apps, apps=args.apps,
is_https=not args.no_ssl, is_https=not args.no_ssl,
@ -775,6 +795,7 @@ if __name__ == "__main__":
version=args.version, version=args.version,
image=args.image, image=args.image,
is_https=not args.no_ssl, is_https=not args.no_ssl,
cronstring=args.backup_schedule,
http_port=args.http_port, http_port=args.http_port,
) )
elif args.subcommand == "exec": elif args.subcommand == "exec":