Reset all database



  • Hi,

    i'm testing data import using nodebb-plugin-write-api.
    After test, i need to reimport data on an empty database (including all index reset).
    How can i reset database (categories,topics,users..) excluding admin user and all configuartion (plugin, theme etc..) ?

    Thanks.


  • Global Moderator

    There's no easy way to do so.



  • Not easy, but managable if you use a mongo database 😄 .

    I did the same. I installed mongo 3.2 in an Ubuntu (virtual) environment. In my local development environment, I did not enable the mongo security setting. This allows me to do the database administration without authentication. Of course you should not do this in your productive environment!

    Create your initial setup as documented. Configure everything according to your needs to the desired state before import.

    Then shutdown nodebb and login to mongo:

    use nodebb
    db.copyDatabase("nodebb", "nodebb-backup-171003")
    

    Now you have a copy, you can restore any time and can start testing your import tool.

    To revert your changes, first shutdown nodebb and login to mongo:

    use nodebb
    db.dropDatabase()
    use nodebb-backup-171003
    db.copyDatabase("nodebb-backup-171003", "nodebb")
    

    You can also switch between the copies of the nodebb databases easily by editing the file config.json.

    Good luck!



  • @frgilb I tried your solution: it's quick, it's secure and it's works :-).
    Thanks


 

Suggested Topics

| |