scheduled every 24 hours but no 24 hour backups
| Project: | Backup and Migrate |
| Version: | 6.x-2.x-dev |
| Component: | Miscellaneous |
| Category: | bug report |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | fixed |
Jump to:
Hi,
I've set your module up to run every 24 hours. Cron runs every night at 1 am, and this is logged as 'cron run completed'.
Yet when I looked at the saved scheduled backups I miss backups;
backup-2009-03-25T00-00-06.sql.gz Wed, 25/03/2009 - 01:00 706.87 KB Download Restore Delete
backup-2009-03-23T00-00-05.sql.gz Mon, 23/03/2009 - 01:00 706.81 KB Download Restore Delete
backup-2009-03-21T00-00-06.sql.gz Sat, 21/03/2009 - 01:00 706.81 KB Download Restore Delete
backup-2009-03-20T00-00-03.sql.gz Fri, 20/03/2009 - 01:00 706.83 KB Download Restore Delete
backup-2009-03-18T00-00-09.sql.gz Wed, 18/03/2009 - 01:00 706.55 KB Download Restore Delete
backup-2009-03-17T00-00-06.sql.gz Tue, 17/03/2009 - 01:00 706.76 KB Download Restore Delete
backup-2009-03-16T00-00-04.sql.gz Mon, 16/03/2009 - 01:00 706.77 KB Download Restore Delete
Missing tue 24/03, sun 22/03, thu 19/03 etc.
Is this a bug or what can possible cause this?
Cheers

#1
This could be a timing issue. When cron runs the module will only do a backup if the last backup was more than 24 hours ago. If it's off by a second it might not meet that criterion.
If your cron is only running once a day, try setting the schedule period to 23 hours and see if it's still happening.
#2
Ok will try and get back to you on this!
I think it would be nice to have a feature, to set backup and migrate to 'daily' or 'weekly' maybe in a cron setting type of way. That way problems like these would be gone. It would check by the date of the backup file. Not if it was created within the last 24 hours...
Setting the cron to run multiple times a day would help. But some hosts don't allow many crons a day specially not ones like the Drupal cron which loads of modules hook into.
Just a thought which might be completely useless ;)
Cheers
#3
This is a common error that I ran into as well. It happens if the scheduled time for your backup is a multiple of the time your cron is running (e.g. cron runs every hour; cron runs every 6 hours and backup is scheduled every 12/18/24/...) hours.
Proposed fix:
change
<?phpif ($last_backup < ($now - ($backup_schedule_period * 60 * 60))) {
?>
to
<?phpif ($last_backup <= ($now - ($backup_schedule_period * 60 * 60))) {
?>
in the backup_migrate_cron function.
#4
I was thinking of just putting a little wiggle room in the check. So if the time is within a few seconds (or a small percentage of the backup period) of when it should run it will run anyway. If simply checking for equality is enough then that's certainly a lot easier. I always assumed that this was as a result of the timing being a little inaccurate, rather than being a little too accurate.
I'v added some code with a 1% timing buffer so hopefully this issue should be fixed for everybody.
The change was made to the 6.x 2.x branch. Let me know if backports are needed.
#5
Thanx for that! Will check it out...
Cheers,
Bartezz