|
67 | 67 | gc/0, |
68 | 68 | get_commands_spec/0, |
69 | 69 | delete_old_messages_batch/4, delete_old_messages_status/1, delete_old_messages_abort/1, |
| 70 | + export_db_ext/4, |
70 | 71 | %% Internal |
71 | 72 | mnesia_list_tables/0, |
72 | 73 | mnesia_table_details/1, |
@@ -466,6 +467,19 @@ get_commands_spec() -> |
466 | 467 | result = {res, restuple}, |
467 | 468 | result_desc = "Result tuple", |
468 | 469 | result_example = {ok, <<"Export started">>}}, |
| 470 | + #ejabberd_commands{name = export_db_ext, tags = [db], |
| 471 | + desc = "Export database records for host to files", |
| 472 | + note = "added in 26.XX", |
| 473 | + module = ejabberd_admin, function = export_db_ext, |
| 474 | + args_desc = ["Name of host that should be exported", |
| 475 | + "Directory name where exported files should be created", |
| 476 | + "List of modules separated by ',' that should be exported, use 'all' to use all available", |
| 477 | + "Type of serialization, recognized values are dbser and json"], |
| 478 | + args_example = [<<"localhost">>, <<"/home/ejabberd/export">>, <<"all">>, <<"json">>], |
| 479 | + args = [{host, binary}, {dir, binary}, {modules, binary}, {type, binary}], |
| 480 | + result = {res, restuple}, |
| 481 | + result_desc = "Result tuple", |
| 482 | + result_example = {ok, <<"Export started">>}}, |
469 | 483 | #ejabberd_commands{name = export_db_status, tags = [db], |
470 | 484 | desc = "Return current status of export operation", |
471 | 485 | note = "added in 26.01", |
@@ -1063,6 +1077,19 @@ import_dir(Path) -> |
1063 | 1077 | {cannot_import_dir, String} |
1064 | 1078 | end. |
1065 | 1079 |
|
| 1080 | +export_db_ext(Host, Dir, <<"all">>, Type) -> |
| 1081 | + export_db_ext(Host, Dir, undefined, Type); |
| 1082 | +export_db_ext(Host, Dir, Modules, Type) when is_binary(Modules) -> |
| 1083 | + Mods = [binary_to_atom(M, latin1) || M <- binary:split(Modules, <<",">>, [global])], |
| 1084 | + export_db_ext(Host, Dir, Mods, Type); |
| 1085 | +export_db_ext(Host, Dir, Mods, <<"json">>) -> |
| 1086 | + ejabberd_db_serialize:export(Host, Dir, Mods, json); |
| 1087 | +export_db_ext(Host, Dir, Mods, <<"dbser">>) -> |
| 1088 | + ejabberd_db_serialize:export(Host, Dir, Mods, dbser). |
| 1089 | + |
| 1090 | + |
| 1091 | + |
| 1092 | + |
1066 | 1093 | %%% |
1067 | 1094 | %%% Purge DB |
1068 | 1095 | %%% |
|
0 commit comments