diff --git a/bench/patches/patches.txt b/bench/patches/patches.txt index 7cb1a076..55a65019 100644 --- a/bench/patches/patches.txt +++ b/bench/patches/patches.txt @@ -5,3 +5,4 @@ bench.patches.v4.update_node bench.patches.v4.update_socketio bench.patches.v4.install_yarn #2 bench.patches.v5.fix_user_permissions +bench.patches.v5.fix_backup_cronjob diff --git a/bench/patches/v5/fix_backup_cronjob.py b/bench/patches/v5/fix_backup_cronjob.py new file mode 100644 index 00000000..15bbfcf3 --- /dev/null +++ b/bench/patches/v5/fix_backup_cronjob.py @@ -0,0 +1,15 @@ +from bench.config.common_site_config import get_config +from crontab import CronTab + + +def execute(bench_path): + """ + This patch fixes a cron job that would backup sites every minute per 6 hours + """ + + user = get_config(bench_path=bench_path).get('frappe_user') + user_crontab = CronTab(user=user) + + for job in user_crontab.find_comment("bench auto backups set for every 6 hours"): + job.every(6).hours() + user_crontab.write() diff --git a/bench/utils.py b/bench/utils.py index d94fc26b..948d62ea 100755 --- a/bench/utils.py +++ b/bench/utils.py @@ -400,7 +400,7 @@ def setup_backups(bench_path='.'): if job_command not in str(system_crontab): job = system_crontab.new(command=job_command, comment="bench auto backups set for every 6 hours") - job.hour.every(6) + job.every(6).hours() system_crontab.write()