]> granicus.if.org Git - ejabberd/commitdiff
Copy, fix and document export2odbc command from mod_admin_extra.erl
authorBadlop <badlop@process-one.net>
Mon, 26 Nov 2012 12:22:29 +0000 (13:22 +0100)
committerBadlop <badlop@process-one.net>
Mon, 26 Nov 2012 12:22:29 +0000 (13:22 +0100)
doc/guide.tex
src/ejabberd_admin.erl
src/ejd2odbc.erl

index 1ecca43104b8afaa8eebd07ef153a018f13a1606..5ac47be89f9ecdfe032ea2af2ecde97cfa88bec4 100644 (file)
@@ -5145,6 +5145,8 @@ The most interesting ones are:
   from other Jabber/XMPP servers
   There exist tutorials to
   \footahref{http://www.ejabberd.im/migrate-to-ejabberd}{migrate from other software to ejabberd}.
+\titem{export2odbc virtualhost directory} \ind{export mnesia data to SQL files}
+  Export virtual host information from Mnesia tables to SQL files.
 \titem{delete\_expired\_messages} This option can be used to delete old messages
   in offline storage. This might be useful when the number of offline messages
   is very high.
index 40c8b8dca667e1ea53249d27cd6a6cb416b69063..e729e4ce0722a0e485cbae77db0060be13a5c23b 100644 (file)
@@ -41,6 +41,7 @@
         %% 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,
@@ -165,6 +166,11 @@ commands() ->
                        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 "
@@ -388,6 +394,23 @@ delete_old_messages(Days) ->
 %%% 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) ->
index 7d96aac3417cc67bb6de59fa6c09c3b3aef17ee1..06b53be403741d514ae274e3c13c80ebd34a0376 100644 (file)
 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),