[GH-ISSUE #1255] Need to re-create modoboa's database #1020

Closed
opened 2026-02-27 11:14:46 +03:00 by kerem · 18 comments
Owner

Originally created by @sorcer1122 on GitHub (Sep 28, 2017).
Original GitHub issue: https://github.com/modoboa/modoboa/issues/1255

Hello,

I was trying to install afterlogic webmail frontend but it messed up my MariaDB and I ended up loosing modoboa's database before I made a backup. So, I would appreciate if anyone could help me to recreate the database again. I have created a user already, created a DB, granted this user rights over the DB and now I am getting the following in postfix log:

warning: mysql query failed: Table 'modoboa.admin_domain' doesn't exist

When I try to create this table, it asks me about columns and I have no idea how many columns I need.

Thanks in advance!

Originally created by @sorcer1122 on GitHub (Sep 28, 2017). Original GitHub issue: https://github.com/modoboa/modoboa/issues/1255 Hello, I was trying to install afterlogic webmail frontend but it messed up my MariaDB and I ended up loosing modoboa's database before I made a backup. So, I would appreciate if anyone could help me to recreate the database again. I have created a user already, created a DB, granted this user rights over the DB and now I am getting the following in postfix log: warning: mysql query failed: Table 'modoboa.admin_domain' doesn't exist When I try to create this table, it asks me about columns and I have no idea how many columns I need. Thanks in advance!
kerem closed this issue 2026-02-27 11:14:46 +03:00
Author
Owner

@tonioo commented on GitHub (Sep 29, 2017):

@sorcer1122 How did you install modoboa?

<!-- gh-comment-id:333049462 --> @tonioo commented on GitHub (Sep 29, 2017): @sorcer1122 How did you install modoboa?
Author
Owner

@sorcer1122 commented on GitHub (Sep 29, 2017):

@tonioo I installed it via the script run.py, so automated installation.

<!-- gh-comment-id:333049667 --> @sorcer1122 commented on GitHub (Sep 29, 2017): @tonioo I installed it via the script run.py, so automated installation.
Author
Owner

@tonioo commented on GitHub (Sep 29, 2017):

Ok, so the easiest way to recreate your database is to run the following commands:

> su - modoboa
> bash
> source env/bin/activate
> cd instance
> python manage.py migrate
> python manage.py load_initial_data
> python manage.py set_default_site <your hostname here>

If it doesn't, drop the modoboa database, recreate it, check permissions and try again.

<!-- gh-comment-id:333052515 --> @tonioo commented on GitHub (Sep 29, 2017): Ok, so the easiest way to recreate your database is to run the following commands: ```bash > su - modoboa > bash > source env/bin/activate > cd instance > python manage.py migrate > python manage.py load_initial_data > python manage.py set_default_site <your hostname here> ``` If it doesn't, drop the modoboa database, recreate it, check permissions and try again.
Author
Owner

@sorcer1122 commented on GitHub (Sep 29, 2017):

@tonioo Thanks!

python manage.py migrate gives me
Operations to perform:
Apply all migrations: admin, auth, authtoken, contenttypes, core, lib, limits, modoboa_amavis, modoboa_contacts, modoboa_postfix_autoreply, relaydomains, reversion, sessions, sites
Running migrations:
No migrations to apply.

python manage.py load_initial_data gives no output

python manage.py set_default_site mydomain.com gives no output

However, it did not help. So, I dropped DB, recreated it and gave permissions:

+------------------------------------------------------------------------+
| Grants for modoboa@% |
+------------------------------------------------------------------------+
| GRANT USAGE ON . TO 'modoboa'@'%' |
| GRANT ALL PRIVILEGES ON modoboa.* TO 'modoboa'@'%' WITH GRANT OPTION |
+------------------------------------------------------------------------+

Still and same output as above after migrate, load_initial_data and set_default_site and DB is still empty, here is what I see in MariaDB:

MariaDB [modoboa]> show tables;
Empty set (0.00 sec)

Any ideas?

<!-- gh-comment-id:333056913 --> @sorcer1122 commented on GitHub (Sep 29, 2017): @tonioo Thanks! **python manage.py migrate** gives me Operations to perform: Apply all migrations: admin, auth, authtoken, contenttypes, core, lib, limits, modoboa_amavis, modoboa_contacts, modoboa_postfix_autoreply, relaydomains, reversion, sessions, sites Running migrations: No migrations to apply. **python manage.py load_initial_data** gives no output **python manage.py set_default_site mydomain.com** gives no output However, it did not help. So, I dropped DB, recreated it and gave permissions: +------------------------------------------------------------------------+ | Grants for modoboa@% | +------------------------------------------------------------------------+ | GRANT USAGE ON *.* TO 'modoboa'@'%' | | GRANT ALL PRIVILEGES ON `modoboa`.* TO 'modoboa'@'%' WITH GRANT OPTION | +------------------------------------------------------------------------+ Still and same output as above after migrate, load_initial_data and set_default_site and DB is still empty, here is what I see in MariaDB: MariaDB [modoboa]> show tables; Empty set (0.00 sec) Any ideas?
Author
Owner

@tonioo commented on GitHub (Sep 29, 2017):

Check the instance/settings.py file to see if you've configured the same database...

<!-- gh-comment-id:333070355 --> @tonioo commented on GitHub (Sep 29, 2017): Check the instance/settings.py file to see if you've configured the same database...
Author
Owner

@sorcer1122 commented on GitHub (Sep 29, 2017):

@tonioo I checked settings.py and I can see that the DB is the same. I have also tried to re-create a user again and granted it all rights over the database, I have ended up with the following (I only need local connection):

+----------------------------------------------------------------------------------------------------------------+
| Grants for modoboa@localhost |
+----------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON . TO 'modoboa'@'localhost' IDENTIFIED BY PASSWORD 'HASH_PASS' |
| GRANT ALL PRIVILEGES ON modoboa.
TO 'modoboa'@'localhost' |
+----------------------------------------------------------------------------------------------------------------+

I am still getting:

MariaDB [modoboa]> show tables;
Empty set (0.00 sec)

I have also tried to log in with my modoboa username & password, open modoboa's DB and create a test table with 1 column, everything works fine but I cannot recreate the default DB structure with the commands you provided above.

<!-- gh-comment-id:333100709 --> @sorcer1122 commented on GitHub (Sep 29, 2017): @tonioo I checked settings.py and I can see that the DB is the same. I have also tried to re-create a user again and granted it all rights over the database, I have ended up with the following (I only need local connection): +----------------------------------------------------------------------------------------------------------------+ | Grants for modoboa@localhost | +----------------------------------------------------------------------------------------------------------------+ | GRANT USAGE ON *.* TO 'modoboa'@'localhost' IDENTIFIED BY PASSWORD '*HASH_PASS' | | GRANT ALL PRIVILEGES ON `modoboa`.* TO 'modoboa'@'localhost' | +----------------------------------------------------------------------------------------------------------------+ I am still getting: MariaDB [modoboa]> show tables; Empty set (0.00 sec) I have also tried to log in with my modoboa username & password, open modoboa's DB and create a test table with 1 column, everything works fine but I cannot recreate the default DB structure with the commands you provided above.
Author
Owner

@tonioo commented on GitHub (Sep 29, 2017):

@sorcer1122 and what happens if you run the migrate command once again ?

<!-- gh-comment-id:333102247 --> @tonioo commented on GitHub (Sep 29, 2017): @sorcer1122 and what happens if you run the migrate command once again ?
Author
Owner

@sorcer1122 commented on GitHub (Sep 29, 2017):

@tonioo All the time same output:

Apply all migrations: admin, auth, authtoken, contenttypes, core, lib, limits, modoboa_amavis, modoboa_contacts, modoboa_postfix_autoreply, relaydomains, reversion, sessions, sites
Running migrations:
No migrations to apply.

<!-- gh-comment-id:333102454 --> @sorcer1122 commented on GitHub (Sep 29, 2017): @tonioo All the time same output: Apply all migrations: admin, auth, authtoken, contenttypes, core, lib, limits, modoboa_amavis, modoboa_contacts, modoboa_postfix_autoreply, relaydomains, reversion, sessions, sites Running migrations: No migrations to apply.
Author
Owner

@sorcer1122 commented on GitHub (Sep 29, 2017):

Not sure whether it is helpful but...

I am also not able to update any extensions. After I do pip install modoboa-.....==1.2.0, extensions is being downloaded but after I do python manage.py migrate, I get 'no migrations to apply'. After python manage.py collectstatic I get '0 static files copied to '/srv/modoboa/instance/sitestatic', 2204 unmodified' and the extension is still there, outdated.

Funnily enough, everything seems to work smoothly: I can add domains, aliases, email users. I am not confused dot com.

<!-- gh-comment-id:333143502 --> @sorcer1122 commented on GitHub (Sep 29, 2017): Not sure whether it is helpful but... I am also not able to update any extensions. After I do pip install modoboa-.....==1.2.0, extensions is being downloaded but after I do python manage.py migrate, I get 'no migrations to apply'. After python manage.py collectstatic I get '0 static files copied to '/srv/modoboa/instance/sitestatic', 2204 unmodified' and the extension is still there, outdated. Funnily enough, everything seems to work smoothly: I can add domains, aliases, email users. I am not confused dot com.
Author
Owner

@tonioo commented on GitHub (Sep 29, 2017):

@sorcer1122 So you're saying everything works as expected now?

<!-- gh-comment-id:333184887 --> @tonioo commented on GitHub (Sep 29, 2017): @sorcer1122 So you're saying everything works as expected now?
Author
Owner

@sorcer1122 commented on GitHub (Sep 29, 2017):

@tonioo it looks like yes, everything is working. I do not see any errors in logs. However, the DB is still empty (weird, isn't it?)

Also, I am not able to update any extensions (as I explained above).

<!-- gh-comment-id:333186393 --> @sorcer1122 commented on GitHub (Sep 29, 2017): @tonioo it looks like yes, everything is working. I do not see any errors in logs. However, the DB is still empty (weird, isn't it?) Also, I am not able to update any extensions (as I explained above).
Author
Owner

@tonioo commented on GitHub (Sep 29, 2017):

Have you reloaded uwsgi?

<!-- gh-comment-id:333194847 --> @tonioo commented on GitHub (Sep 29, 2017): Have you reloaded uwsgi?
Author
Owner

@sorcer1122 commented on GitHub (Sep 29, 2017):

Thanks, I can now see the updated extension!!! Completely forgot about uwsgi...Perhaps you should amend the manual - https://modoboa.readthedocs.io/en/latest/upgrade.html ...after phrase 'Finally, restart your web server' you can add something like 'and uwsgi'.

I am a little bit confused about the DB though. Not sure where modoboa keeps its data...do you think it will work smoothly without a single record in the DB?

<!-- gh-comment-id:333199103 --> @sorcer1122 commented on GitHub (Sep 29, 2017): Thanks, I can now see the updated extension!!! Completely forgot about uwsgi...Perhaps you should amend the manual - https://modoboa.readthedocs.io/en/latest/upgrade.html ...after phrase 'Finally, restart your web server' you can add something like 'and uwsgi'. I am a little bit confused about the DB though. Not sure where modoboa keeps its data...do you think it will work smoothly without a single record in the DB?
Author
Owner

@sorcer1122 commented on GitHub (Sep 29, 2017):

Not sure whether this is related but I am now unable to send mail via webmail. Gives me error 500 with the following in the console:

POST https://mydomain.com/webmail/?action=compose 500 ()
(anonymous) @ VM492:1
send @ jquery.min.js:5
ajax @ jquery.min.js:5
sendmail @ webmail.js:1044
i @ jquery.min.js:3
dispatch @ jquery.min.js:3
v.handle @ jquery.min.js:3

in /var/log/mail.log I can see:

connection established from...
lost connection after AUTH from...
disconnect...

If I do postmap -q user@mydomain.com mysql:/etc/postfix/sql-domains.cf I get the following output:

postmap: warning: mysql query failed: Table 'modoboa.admin_domain' doesn't exist
postmap: fatal: table mysql:/etc/postfix/sql-domains.cf: query error: Success

Clearly, there is a problem in the DB. Is there a list of all the tables necessary for modoboa DB?

:(

<!-- gh-comment-id:333204495 --> @sorcer1122 commented on GitHub (Sep 29, 2017): Not sure whether this is related but I am now unable to send mail via webmail. Gives me error 500 with the following in the console: POST https://mydomain.com/webmail/?action=compose 500 () (anonymous) @ VM492:1 send @ jquery.min.js:5 ajax @ jquery.min.js:5 sendmail @ webmail.js:1044 i @ jquery.min.js:3 dispatch @ jquery.min.js:3 v.handle @ jquery.min.js:3 in /var/log/mail.log I can see: connection established from... lost connection after AUTH from... disconnect... If I do **postmap -q user@mydomain.com mysql:/etc/postfix/sql-domains.cf** I get the following output: postmap: warning: mysql query failed: Table 'modoboa.admin_domain' doesn't exist postmap: fatal: table mysql:/etc/postfix/sql-domains.cf: query error: Success Clearly, there is a problem in the DB. Is there a list of all the tables necessary for modoboa DB? :(
Author
Owner

@tonioo commented on GitHub (Oct 2, 2017):

You should not have to deal with that. Are you using a mysql cluster or similar?

<!-- gh-comment-id:333573706 --> @tonioo commented on GitHub (Oct 2, 2017): You should not have to deal with that. Are you using a mysql cluster or similar?
Author
Owner

@sorcer1122 commented on GitHub (Oct 2, 2017):

I am using MariaDB. It was a default installation and I don't think clustering is enabled

<!-- gh-comment-id:333649471 --> @sorcer1122 commented on GitHub (Oct 2, 2017): I am using MariaDB. It was a default installation and I don't think clustering is enabled
Author
Owner

@sorcer1122 commented on GitHub (Oct 4, 2017):

Still cannot send any emails via webmail, error 500 all the time and nothing specific in logs. Also, I am not able to create any user with error 400

P.S. Found this in the debug console while trying to send an email: "character mapping must return integer, None or unicode"

<!-- gh-comment-id:334043642 --> @sorcer1122 commented on GitHub (Oct 4, 2017): Still cannot send any emails via webmail, error 500 all the time and nothing specific in logs. Also, I am not able to create any user with error 400 P.S. Found this in the debug console while trying to send an email: "character mapping must return integer, None or unicode"
Author
Owner

@sorcer1122 commented on GitHub (Oct 4, 2017):

Resolved, many thanks for the interest!

<!-- gh-comment-id:334226137 --> @sorcer1122 commented on GitHub (Oct 4, 2017): Resolved, many thanks for the interest!
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/modoboa-modoboa#1020
No description provided.