%% Purge DB
delete_expired_messages/0, delete_old_messages/1,
%% Mnesia
+ export2odbc/2,
set_master/1,
backup_mnesia/1, restore_mnesia/1,
dump_mnesia/1, dump_table/2, load_mnesia/1,
module = mod_pubsub, function = rename_default_nodeplugin,
args = [], result = {res, rescode}},
+ #ejabberd_commands{name = export2odbc, tags = [mnesia],
+ desc = "Export virtual host information from Mnesia tables to SQL files",
+ module = ?MODULE, function = export2odbc,
+ args = [{host, string}, {directory, string}],
+ result = {res, rescode}},
#ejabberd_commands{name = set_master, tags = [mnesia],
desc = "Set master node of the clustered Mnesia tables",
longdesc = "If you provide as nodename \"self\", this "
%%% Mnesia management
%%%
+export2odbc(Host, Directory) ->
+ Tables = [{export_last, last},
+ {export_offline, offline},
+ {export_private_storage, private_storage},
+ {export_roster, roster},
+ {export_vcard, vcard},
+ {export_vcard_search, vcard_search},
+ {export_passwd, passwd}],
+ Export = fun({TableFun, Table}) ->
+ Filename = filename:join([Directory, atom_to_list(Table)++".txt"]),
+ io:format("Trying to export Mnesia table '~p' on Host '~s' to file '~s'~n", [Table, Host, Filename]),
+ Res = (catch ejd2odbc:TableFun(Host, Filename)),
+ io:format(" Result: ~p~n", [Res])
+ end,
+ lists:foreach(Export, Tables),
+ ok.
+
set_master("self") ->
set_master(node());
set_master(NodeString) when is_list(NodeString) ->
export_passwd(Server, Output) ->
export_common(
Server, passwd, Output,
- fun(Host, {passwd, {LUser, LServer}, Password} = _R)
+ fun(Host, {passwd, {LUser, LServer}, {scram, _, _, _, _}} = _R) ->
+ ?INFO_MSG("You are trying to export the authentication "
+ "information of the account ~s@~s, but his password "
+ "is stored as SCRAM, and ejabberd ODBC authentication "
+ "doesn't support SCRAM.", [LUser, LServer]),
+ [];
+ (Host, {passwd, {LUser, LServer}, Password} = _R)
when LServer == Host ->
Username = ejabberd_odbc:escape(LUser),
Pass = ejabberd_odbc:escape(Password),