Use Mnesia backup on other machines
ngocdaothanh
ngocdaothanh@REDACTED
Tue Sep 1 04:53:26 CEST 2009
Thank you for the answers.
> Is this about the actual file movement, or about whether a mnesia backup done on cluster A can be restored on cluster B?
I mean for a same version of Erlang, is the default backup file cross-
platform and can be restored anywhere just like a PostgreSQL backup
file? How can I create backup file on a remote server running Ubuntu,
then restore it to my local Snow Leopard laptop? I heard somewhere
that once created a Mnesia DB will be fixed to a node name, simply
copying it doesn't work.
> until_next_time() function from crone
crone is very interesting. Where can I find the latest version of it?
Regards.
On Sep 1, 2:34 am, Robert Raschke <rtrli...@REDACTED> wrote:
> On Mon, Aug 31, 2009 at 5:43 PM, Paul Mineiro <paul-trape...@REDACTED>wrote:
>
>
>
> > Inline.
>
> > -- p
>
> > On Sun, 30 Aug 2009, ngocdaothanh wrote:
>
> > > Hi everyone,
>
> > > I would like to ask about Mnesia backup:
> > > 1. How to periodically create backup of Mnesia DB of a node?
>
> > You can have a gen_server which uses timer:send_interval/2 combined with
> > handle_info/2 to trigger the backups. You can back up everything with
> > mnesia:backup/1. In case the backup takes a very long time you should
> > twiddle something in the gen_server state to prevent starting a new backup
> > while an old one is happening.
>
> No need for the timer though, just use the gen_server's own timeout return
> value. Combine this with calculating a timeout value using the
> until_next_time() function from crone and you can have nicely scheduled
> backups.
>
> Minimal, untested and not even compiled example, started with something like
> mybackup:start_link("DB.BAK", {daily, {every, {1, hr}, {between, {12, 0, 0,
> am}, {11, 59, 59, pm}}}}) .
>
> -module(mybackup).
>
> -behaviour(gen_server).
>
> -export([start_link/2, init/1, handle_info/2]).
>
> start_link(Backup_File, Backup_When) ->
> gen_server:start_link({local, ?MODULE}, ?MODULE, [Backup_File,
> Backup_When], []).
>
> init([Backup_File, Backup_When]) ->
> {ok, {Backup_File, Backup_When},
> 1000*crone:until_next_time(Backup_When)}.
>
> handle_info(timeout, {Backup_File, Backup_When} = State) ->
> mnesia:backup(Backup_File),
> % HACK: Just in case it took less than a second, make sure we don't do
> it again right away.
> timer:sleep(1000),
> {noreply, State, 1000*crone:until_next_time(Backup_When)}.
>
> Robby
More information about the erlang-questions
mailing list