From the link above: ( http://www.robgroen.nl/content/zpanel-cr...ps-one-day )
Pasted here in case something happens on that site. I will also test out the code and push the changes to github if successful.
Pasted here in case something happens on that site. I will also test out the code and push the changes to github if successful.
Quote:ZPanel creates multiple backups on one day
Suddenly my ZPanel began making multiple backups on one day. Looking at the filename of the backup it looks like the backups are made 1 sec after another.
Backup has file names like this
Code:zadmin_Oct-18-2014_051006.zip
zadmin_Oct-18-2014_051007.zip
zadmin_Oct-18-2014_051008.zip
Actually the file are not made 1 sec after another but 5 minutes. Looking at the file system in the backup directories confirm that. So why is the filename telling me something others than that? There is a bug in the script that defines the filename.
Minutes
Using the date php date format character hms is not hour minute seconds but hours month seconds So changing the "m" into a "i" gives you the minutes.
Hour
Also the hours are wrong defined "h" gives me the 01-12 hour definition without AM or PM. So i think 00-23 in this case is better. Change the "h" into a "H" for 24 hour definition in the time.
Seconds
Seconds "s" is OK
Code:cd /etc/zpanel/panel/modules/backup_admin/hook
cp OnDaemonDay.hook.php OnDaemonDay.hook.php.$(date +%Y%m%d-%H%m%S)
vi OnDaemonDay.hook.php
Change line 34 from
Code:$backupname = $username . "_" . date("M-d-Y_hms", time());
to
Code:$backupname = $username . "_" . date("M-d-Y_His", time());
Actually I suppose the multi backup issue is triggered if the total time that is takes to make all backups is longer than the pauses between two cron deamon jobs (default is 5 minutes). This problem is created in /etc/zpanel/panel/bin/daemon.php The dayrun takes more takes 5 minutes and the time is reset after all three jobs are done.
I changes this code to:
Code:if (ctrl_options::GetSystemOption('daemon_dayrun') < (time() - 86399)) {
runtime_hook::Execute("OnStartDaemonDay");
runtime_hook::Execute("OnDaemonDay");
runtime_hook::Execute("OnEndDaemonDay");
ctrl_options::SetSystemOption('daemon_dayrun', time());
}
This:
Code:if (ctrl_options::GetSystemOption('daemon_dayrun') < (time() - 86399)) {
ctrl_options::SetSystemOption('daemon_dayrun', time());
runtime_hook::Execute("OnStartDaemonDay");
runtime_hook::Execute("OnDaemonDay");
runtime_hook::Execute("OnEndDaemonDay");
}
Just moved the line ctrl_options::SetSystemOption('daemon_dayrun', time()); up three lines.