mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-08 21:43:07 +02:00
* src/mod_configure.erl: Unknown tables or tables from now
unused modules are ignored during restore. The restore can now be performed in such case (EJAB-80). * src/web/ejabberd_web_admin.er: Likewise. * src/ejabberd_admin.erl: Likewise. Code refactoring. Common Mnesia database restore function. SVN Revision: 562
This commit is contained in:
parent
c57ca8a483
commit
ba55665381
|
@ -1,3 +1,12 @@
|
||||||
|
2006-05-07 Mickael Remond <mickael.remond@process-one.net>
|
||||||
|
|
||||||
|
* src/mod_configure.erl: Unknown tables or tables from now unused
|
||||||
|
modules are ignored during restore. The restore can now be performed in
|
||||||
|
such case.
|
||||||
|
* src/web/ejabberd_web_admin.er: Likewise.
|
||||||
|
* src/ejabberd_admin.erl: Code refactoring. Common Mnesia database
|
||||||
|
restore function.
|
||||||
|
|
||||||
2006-05-01 Mickael Remond <mickael.remond@process-one.net>
|
2006-05-01 Mickael Remond <mickael.remond@process-one.net>
|
||||||
|
|
||||||
* src/ejabberd_ctl.erl: Unknown tables or tables from now unused
|
* src/ejabberd_ctl.erl: Unknown tables or tables from now unused
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
-module(ejabberd_ctl).
|
-module(ejabberd_ctl).
|
||||||
-author('alexey@sevcom.net').
|
-author('alexey@sevcom.net').
|
||||||
|
-vsn('$Revision$ ').
|
||||||
|
|
||||||
-export([start/0,
|
-export([start/0,
|
||||||
init/0,
|
init/0,
|
||||||
|
@ -123,8 +124,7 @@ process(["load", Path]) ->
|
||||||
end;
|
end;
|
||||||
|
|
||||||
process(["restore", Path]) ->
|
process(["restore", Path]) ->
|
||||||
case mnesia:restore(Path, [{keep_tables,keep_tables()},
|
case ejabberd_admin:restore(Path) of
|
||||||
{default_op, skip_tables}]) of
|
|
||||||
{atomic, _} ->
|
{atomic, _} ->
|
||||||
?STATUS_SUCCESS;
|
?STATUS_SUCCESS;
|
||||||
{error, Reason} ->
|
{error, Reason} ->
|
||||||
|
@ -328,35 +328,3 @@ dump_tab(F, T) ->
|
||||||
fun() -> mnesia:match_object(T, W, read) end),
|
fun() -> mnesia:match_object(T, W, read) end),
|
||||||
lists:foreach(
|
lists:foreach(
|
||||||
fun(Term) -> io:format(F,"~p.~n", [setelement(1, Term, T)]) end, All).
|
fun(Term) -> io:format(F,"~p.~n", [setelement(1, Term, T)]) end, All).
|
||||||
|
|
||||||
%% This function return a list of tables that should be kept from a previous
|
|
||||||
%% version backup.
|
|
||||||
%% Obsolete tables or tables created by module who are no longer used are not
|
|
||||||
%% restored and are ignored.
|
|
||||||
keep_tables() ->
|
|
||||||
lists:flatten([acl, passwd, config, local_config, disco_publish,
|
|
||||||
keep_modules_tables()]).
|
|
||||||
|
|
||||||
%% Return the list of modules tables in use, according to the list of actually
|
|
||||||
%% loaded modules
|
|
||||||
keep_modules_tables() ->
|
|
||||||
lists:map(fun(Module) ->
|
|
||||||
module_tables(Module)
|
|
||||||
end,
|
|
||||||
gen_mod:loaded_modules(?MYNAME)).
|
|
||||||
|
|
||||||
%% TODO: This mapping should probably be moved to a callback function in each
|
|
||||||
%% module.
|
|
||||||
%% Mapping between modules and their tables
|
|
||||||
module_tables(mod_announce) -> [motd, motd_users];
|
|
||||||
module_tables(mod_irc) -> [irc_custom];
|
|
||||||
module_tables(mod_last) -> [last_activity];
|
|
||||||
module_tables(mod_muc) -> [muc_room, muc_registered];
|
|
||||||
module_tables(mod_offline) -> [offline_msg];
|
|
||||||
module_tables(mod_privacy) -> [privacy];
|
|
||||||
module_tables(mod_private) -> [private_storage];
|
|
||||||
module_tables(mod_pubsub) -> [pubsub_node];
|
|
||||||
module_tables(mod_roster) -> [roster];
|
|
||||||
module_tables(mod_shared_roster) -> [sr_group, sr_user];
|
|
||||||
module_tables(mod_vcard) -> [vcard, vcard_search];
|
|
||||||
module_tables(_Other) -> [].
|
|
||||||
|
|
|
@ -1126,8 +1126,7 @@ set_form(_Host, ["running nodes", ENode, "backup", "restore"], _Lang, XData) ->
|
||||||
false ->
|
false ->
|
||||||
{error, ?ERR_BAD_REQUEST};
|
{error, ?ERR_BAD_REQUEST};
|
||||||
{value, {_, [String]}} ->
|
{value, {_, [String]}} ->
|
||||||
case rpc:call(Node, mnesia, restore,
|
case rpc:call(Node, ejabberd_admin, restore, [String]) of
|
||||||
[String, [{default_op, keep_tables}]]) of
|
|
||||||
{badrpc, _Reason} ->
|
{badrpc, _Reason} ->
|
||||||
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
{error, ?ERR_INTERNAL_SERVER_ERROR};
|
||||||
{error, _Reason} ->
|
{error, _Reason} ->
|
||||||
|
|
|
@ -5,8 +5,8 @@
|
||||||
%%% Created : 9 Apr 2004 by Alexey Shchepin <alexey@sevcom.net>
|
%%% Created : 9 Apr 2004 by Alexey Shchepin <alexey@sevcom.net>
|
||||||
%%% Id : $Id$
|
%%% Id : $Id$
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
%%% Copyright (c) 2004-2005 Alexey Shchepin
|
%%% Copyright (c) 2004-2006 Alexey Shchepin
|
||||||
%%% Copyright (c) 2004-2005 Process One
|
%%% Copyright (c) 2004-2006 Process One
|
||||||
%%%----------------------------------------------------------------------
|
%%%----------------------------------------------------------------------
|
||||||
|
|
||||||
-module(ejabberd_web_admin).
|
-module(ejabberd_web_admin).
|
||||||
|
@ -2179,10 +2179,8 @@ node_backup_parse_query(Node, Query) ->
|
||||||
rpc:call(Node, mnesia,
|
rpc:call(Node, mnesia,
|
||||||
backup, [Path]);
|
backup, [Path]);
|
||||||
"restore" ->
|
"restore" ->
|
||||||
rpc:call(Node, mnesia,
|
rpc:call(Node, ejabberd_admin,
|
||||||
restore,
|
restore, [Path]);
|
||||||
[Path, [{default_op,
|
|
||||||
keep_tables}]]);
|
|
||||||
"fallback" ->
|
"fallback" ->
|
||||||
rpc:call(Node, mnesia,
|
rpc:call(Node, mnesia,
|
||||||
install_fallback, [Path]);
|
install_fallback, [Path]);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user