Restore from Dump File, Not working

We are attempting to make a change to the DB, and thought we could do it through the Dump to a text File and Restore from a Text File functions. When we try the restore the database remains unchanged.

Any help weould be greatly appreciated.

Thanks,
Brian Corbet

'load' adds or modifies registers, it does not remove

When we try the restore the database remains unchanged.

That depends on the changes. If you modify or add new registers to a table, they should be updated when you load the file. If you remove registers, they are not removed from the DB.

There are two (non excluding) possibilities:

  1. There's a bug in ejabberd that prevents it from working as it was intended
  2. It works as intended, but you are not aware of the intention at all.

Let's suppose there is no bug. Now let's understand the dump and load processes:

  • Dump: dumps all the tables in the Mnesia database to a single file, in text format so you can modify it.
  • Load: it loads the tables found in a text file, and adds the information to the currently available on the tables. If two elements have the same key, the old one is removed and the one in the dump file is inserted.

Example:

$ ejabberdctl ... dump aa.txt
$ ejabberdctl ... load aa.txt
** Table local_config already exists on ejabberd2@atenea, just entering data
** Table config already exists on ejabberd2@atenea, just entering data
** Table privacy already exists on ejabberd2@atenea, just entering data
** Table passwd already exists on ejabberd2@atenea, just entering data
** Table irc_custom already exists on ejabberd2@atenea, just entering data
** Table roster already exists on ejabberd2@atenea, just entering data
** Table last_activity already exists on ejabberd2@atenea, just entering data
** Table sr_user already exists on ejabberd2@atenea, just entering data
** Table offline_msg already exists on ejabberd2@atenea, just entering data
** Table motd already exists on ejabberd2@atenea, just entering data
** Table acl already exists on ejabberd2@atenea, just entering data
** Table disco_publish already exists on ejabberd2@atenea, just entering data
** Table vcard already exists on ejabberd2@atenea, just entering data
** Table sr_group already exists on ejabberd2@atenea, just entering data
** Table vcard_search already exists on ejabberd2@atenea, just entering data
** Table motd_users already exists on ejabberd2@atenea, just entering data
** Table private_storage already exists on ejabberd2@atenea, just entering data
** Table muc_room already exists on ejabberd2@atenea, just entering data
** Table muc_registered already exists on ejabberd2@atenea, just entering data
** Table pubsub_node already exists on ejabberd2@atenea, just entering data

If you remove elements in the dump, when you load it they will still be on the DB. If you want to actually remove registers on the tables: dump DB to file, modify file, remove DB, load file into DB.

How to remove the Mnesia database: stop ejabberd, remove the spool directory (it contains files called acl.DTD...), start ejabberd and the database will be created from scratch.

Do I understand correctly?

So after I remove the spool directory, and it creates it from scratch I then do a restore from the Dump file? This should restore all our Rosters and V-Card info then too, correct?

Thanks,
Brian C.

Yes, it fills the new empty

Yes, it fills the new empty database with the content previously stored in the dump file.

Can I Stage the Restore?

Would it be possible to make a new installation of EJabberd on a non-prod machine, restore the modified Dump File, then make a Backup instead of a dump from the non-prod, and restore that backup file to the Production server? Does the restoring a backup file completely erase the current DB with the restore file, unlike the way the restore dump file process works?

Thanks,
Brian Corbet

Mnesia backup/restore commands explained

Looking at source code, and adding the descriptions found in the Mnesia documentation, we get this raw explanation of the ejabberd commands:

  • backup file - store a database backup to file - mnesia:backup

    Activates a new checkpoint covering all Mnesia tables, including the schema, with maximum degree of redundancy and performs a backup using backup_checkpoint/2.

    The tables are backed up to external media using the backup module BackupMod. Tables with the local contents property is being backed up as they exist on the current node.

  • restore file - restore a database backup from file - mnesia:restore(Path, [{default_op, keep_tables}])

    With this function, tables may be restored online from a backup without restarting Mnesia. The records in the backup will be added to the records in the table.

  • install-fallback file - install a database fallback from file - mnesia:install_fallback

    This function is used to install a backup as fallback. The fallback will be used to restore the database at the next start-up.

    Installation of fallbacks requires Erlang to be up and running on all the involved nodes, but it does not matter if Mnesia is running or not. The installation of the fallback will fail if the local node is not one of the disc resident nodes in the backup.

  • dump file -dump a database to a text file - mnesia:dump_to_textfile

    Dumps all local tables of a mnesia system into a text file which can then be edited (by means of a normal text editor) and then later be reloaded with mnesia:load_textfile/1. Only use this function for educational purposes. Use other functions to deal with real backups.

  • load file - restore a database from a text file - mnesia:load_textfile

    Loads a series of definitions and data found in the text file (generated with mnesia:dump_to_textfile/1) into Mnesia. This function also starts Mnesia and possibly creates a new schema. This function is intended for educational purposes only and using other functions to deal with real backups, is recommended.

Syndicate content