Page 1 of 1

Feature Request: Automated Database Nightly Backup

Posted: Fri Oct 01, 2010 3:48 am
by Brook
I am sure someone has thought of this before...

Can someone create a module that would automatically backup the OpenCart database at a specified time of day.
Example: automated backup the database at 2:00 AM CST everyday (or backup however many times a day). The key part is that it would be an automated process that would run however many times a day to backup the database.

As a user of this module, all you would do is
1) Login to the admin website
2) Set the time or times for the database backup
3) Specify the folder location for the destination of the database backup file
4) The database would be backed up and saved to a file on the web server in the specified folder

Re: Feature Request: Automated Database Nightly Backup

Posted: Fri Oct 01, 2010 8:13 am
by JAY6390
One key issue with this, to get it to run, you would require the store owner to set up a cron job before doing this, which means you would need them to understand how to edit cron's

Re: Feature Request: Automated Database Nightly Backup

Posted: Fri Oct 01, 2010 9:10 am
by Qphoria
Well you could have it run daily at some interval just like the autoupdate currency does. Simply put the trigger in the admin page and when ever a page is loaded in the admin, if 24 has gone by, run the backup.

Re: Feature Request: Automated Database Nightly Backup

Posted: Fri Oct 01, 2010 9:12 am
by JAY6390
Yeah, but that isn't really automated is it? What if your admin only works mon - fri, and doesn't log in on the weekends, you're going to miss two days of backups...not really ideal. I understand what you mean, but for a proper automated system, crons are the only solution

Re: Feature Request: Automated Database Nightly Backup

Posted: Fri Oct 01, 2010 9:42 am
by Qphoria
Silence! It is much more likely that you will login to your store more than that. It works fine for the currency thing and its more than you got now and less confusing than cron.

Re: Feature Request: Automated Database Nightly Backup

Posted: Fri Oct 01, 2010 9:47 am
by OC2PS
Can a cron job be *automatically* be scheduled by the module script itself? vTiger seems to be able to handle crons without needing users to exit the admin panel...

Re: Feature Request: Automated Database Nightly Backup

Posted: Fri Oct 01, 2010 9:49 am
by Qphoria
well this aint vtiger :)
crons only work on linux boxes so its only a partial solution. Not sure how to interface with task scheduler on a windows box.

Re: Feature Request: Automated Database Nightly Backup

Posted: Fri Oct 01, 2010 9:52 am
by OC2PS
Come to think of it, what about all these "webcalendar" scripts that let you schedule "reminders" from their web interfaces?

Re: Feature Request: Automated Database Nightly Backup

Posted: Fri Oct 01, 2010 10:06 am
by JAY6390
True, Windows will make it trickier, since you'll need to use the scheduled tasks editor (or task scheduler in windows 7). Getting a module to have access to something that advanced really isn't something I would advise. Pretty sure you would need to have a script running as a particular user with certain rights to the /etc/crontab. This is something that people should be able to do fairly easily with cpanel and maybe plesk (although last time I looked it wasn't that simple), but other than that, I think its going to be more hassle than it's worth

As for the logins being more frequent than what I put, it really depends on the store IMO, not all stores get sales in mass volumes or even every day, and people go on holidays etc, so their admin doesn't get used during these periods. I realise that these aren't things that happen all the time, but they do happen. I'd personally want my backups done at regular intervals rather than the first time I used my admin panel after 24 hours from the previous backup, preferably at a time where users are at their lowest during the day, to risk any issues or db overloading

Re: Feature Request: Automated Database Nightly Backup

Posted: Fri Oct 01, 2010 10:07 am
by Qphoria
still once a month is better than never

Or put the trigger on the store front. search engine crawls will trigger it

Re: Feature Request: Automated Database Nightly Backup

Posted: Fri Oct 01, 2010 10:13 am
by JAY6390
Well that might be the solution. All that's needed now is a backup script :P

Re: Feature Request: Automated Database Nightly Backup

Posted: Sat Oct 02, 2010 12:22 am
by Moggin
Qphoria wrote:Silence! It is much more likely that you will login to your store more than that.
Autocratic or what! :laugh:

I'll add a vote for this idea too. I don't know enough to be let loose with a cron job, but like the idea of a backup triggered by admin or front office event.

Re: Feature Request: Automated Database Nightly Backup

Posted: Sat Oct 02, 2010 5:49 am
by OC2PS
I assume (hope) admin module logins are less frequent than frontend visits. To reduce database queries (shared hosts usually cap them), I would prefer triggering backup based on admin module login....i.e. when I log into admin, the script checks if it has been 24 hrs since last backup, etc

Re: Feature Request: Automated Database Nightly Backup

Posted: Sat Oct 02, 2010 6:24 pm
by JAY6390
To check the last time the db was backed up could be run from a config setting, which is loaded each and every time a page is loaded anyway, so it wouldn't make a difference whether it was run of the back end and/or front end really

Re: Feature Request: Automated Database Nightly Backup

Posted: Mon Oct 04, 2010 1:38 am
by hodet
I use this;
http://www.dagondesign.com/articles/aut ... up-script/

Then I wrote a bash script (called from cron) that also zips my website, encrypts the database output from the script and the website directory tree (with gpg) and emails it at 1:00am each night to an offsite email account.

At the end of the day I have a local copy of last nights backup and an offsite backup. Its actually saved my bacon once.

Re: Feature Request: Automated Database Nightly Backup

Posted: Mon Oct 04, 2010 10:35 pm
by i2Paq
When usıng a VPS wıth Plex (or maybe cPanel) there are some tools that wıll let you backup you mySQL automatıcly.
Contact you hoster and ask what they can offer you.