mod_cron for backup

I have ejabberd 1.1.3 running for a year (Win XP) and is now trying to add scheduled backup using mod_cron.

I have installed mod_cron, and change the ejabberd.cfg file to include:

{modules,
[
....
% mod_cron
%
{mod_cron, [{tasks, [
{10, minutes, ejabberd_ctl, backup, ["C:/Program Files/ejabberd-1.1.3/bin/ejabberd.backup"]}
% {3, hours, mnesia, info, []},
% {1, days, ejabberd_auth, try_register, ["aaa", "atenea", "aaaaaa"]}
]}]},
....

On restarting ejabberd and after 10 minutes, the following error is reported in the ejabberd.log:

=ERROR REPORT==== 2008-02-07 10:08:43 ===
E(<0.418.0>:mod_cron:85): Error in scheduled task ejabberd_ctl:backup["C:/Program Files/ejabberd-1.1.3/bin/ejabberd.backup"]:
{undef,[{ejabberd_ctl,backup,
["C:/Program Files/ejabberd-1.1.3/bin/ejabberd.backup"]},
{mod_cron,run_task,3}]}

=ERROR REPORT==== 2008-02-07 10:08:43 ===
E(<0.419.0>:mod_cron:85): Error in scheduled task ejabberd_ctl:backup["C:/Program Files/ejabberd-1.1.3/bin/ejabberd.backup"]:
{undef,[{ejabberd_ctl,backup,
["C:/Program Files/ejabberd-1.1.3/bin/ejabberd.backup"]},
{mod_cron,run_task,3}]}

=ERROR REPORT==== 2008-02-07 10:08:43 ===
E(<0.420.0>:mod_cron:85): Error in scheduled task ejabberd_ctl:backup["C:/Program Files/ejabberd-1.1.3/bin/ejabberd.backup"]:
{undef,[{ejabberd_ctl,backup,
["C:/Program Files/ejabberd-1.1.3/bin/ejabberd.backup"]},
{mod_cron,run_task,3}]}

It appears that mod_cron is running. What have I done wrong? Pls help. Thank you in advance.

Rgds,

YsK

Wrong task data

yskwong wrote:

{modules,
[
....
{mod_cron, [{tasks, [
{10, minutes, ejabberd_ctl, backup, ["C:/Program Files/ejabberd-1.1.3/bin/ejabberd.backup"]}
]}]},
....

I think you don't need to make a backup of the database every 10 minutes. Note that ejabberd consumes a lot of RAM and CPU when doing a backup of a big database. And the database is stored in the spool directory anyway. So the purpose of making a backup is to store it in a different machine in case of a serious hard drive crash, etc.

yskwong wrote:

On restarting ejabberd and after 10 minutes, the following error is reported in the ejabberd.log:

=ERROR REPORT==== 2008-02-07 10:08:43 ===
E(<0.418.0>:mod_cron:85): Error in scheduled task ejabberd_ctl:backup["C:/Program Files/ejabberd-1.1.3/bin/ejabberd.backup"]:
{undef,[{ejabberd_ctl,backup,
["C:/Program Files/ejabberd-1.1.3/bin/ejabberd.backup"]},
{mod_cron,run_task,3}]}

=ERROR REPORT==== 2008-02-07 10:08:43 ===
E(<0.419.0>:mod_cron:85): Error in scheduled task ejabberd_ctl:backup["C:/Program Files/ejabberd-1.1.3/bin/ejabberd.backup"]:
{undef,[{ejabberd_ctl,backup,
["C:/Program Files/ejabberd-1.1.3/bin/ejabberd.backup"]},
{mod_cron,run_task,3}]}

=ERROR REPORT==== 2008-02-07 10:08:43 ===
E(<0.420.0>:mod_cron:85): Error in scheduled task ejabberd_ctl:backup["C:/Program Files/ejabberd-1.1.3/bin/ejabberd.backup"]:
{undef,[{ejabberd_ctl,backup,
["C:/Program Files/ejabberd-1.1.3/bin/ejabberd.backup"]},
{mod_cron,run_task,3}]}

Where did you read about ejabberd_ctl backup? This is not correct. Try with

{10, minutes, ejabberd_ctl, process, [[backup, "C:/Program Files/ejabberd-1.1.3/bin/ejabberd.backup"]]}

or maybe

{10, minutes, mnesia, backup, ["C:/Program Files/ejabberd-1.1.3/bin/ejabberd.backup"]}

Also, you get the error three times. Do you have three vhosts in your ejabberd server? Note that the database backup will backup all the database. So you only need to backup the database once. If you define mod_cron as explained in the README.txt, the module is started for each vhost, and it will make the same identical backup three times!

This can be solved using the configuration 'host_config' in ejabberd 2.0.0, so that you can enable mod_cron only in a specific vhost.

mod_cron for backup

Thanks for the comments and suggestion.

I am planning on doing a database backup only once a day or so, not every 10 min. The 10 min setting is only for testing. For obvious reason, I do not want to wait 24 hours to find out if the mod_cron setting is working or not.

I try both of your suggestions for scheduled backup with mod_cron. The one with mnesia works perfectly, whereas the one with ejabberd_ctl does not work at all. But I do have a working solution now.

I am aware of that ejabberd 1.1.3 will backup once for each vhost. Will switch to 2.0 release when we are ready. Thanks again.

Syndicate content