google / import-mailbox-to-gmail

Import .mbox files into Google Workspace

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Useful app but I am stuck on the last step

opened this issue · comments

Everything works perfectly fine. But, when the last step of importing is not working for me. Nothing happens when I run that command. Please help!

Hi,

Can you share a screenshot of what you're seeing? Make sure to block out any private information, of course.

Nothing actually, no error message. I just run the command replacing the location of the json file and the mbox folder. But, nothing happens.

try looking in the log file, which method are you using? Windows/Linux?

Where I can view the log file? I am using Windows.

The log file should be import-mbox-to-gmail.log. If you can't find it, can you share a screenshot of the command you're running?

commented

Hi,
Please excuse me for jumping in on this thread, but I'm having the same issue. Using Win 2012 server... running the final command gets no response from the Windows Command line (as admin). However I do get syntax errors using the Python command line.

Created folders as instructed. c:\mbox\
User folder is jon_doh@ddouglas.k12.or.us
I also placed the JSON file in the C:\mbox directory.

Here's the command I'm running...

import-mbox-to-gmail.py --json c:\mbox\GmailRestore-605fbe12b095.json --dir c:\mbox\jon_doh@ddouglas.k12.or.us --replaceqp >> import-mbox-to-gmail.log 2>&1

I can't see the error. Do I need to include the actual .mbox file in the user directory folder in the path?
e.g. "c:\mbox\jon_doh@ddouglas.k12.or.us\restored.mbox"

  1. Even if you are migrating only one user, the folder you need to point the script at is still the one with the user's folder in it, not directly to the user's folder. In your case, you should run it with "--dir c:\mbox" instead of "--dir c:\mbox\jon_doh@ddouglas.k12.or.us", if I understand your setup correctly.
  2. Yes, in this case, the mbox file would be in "c:\mbox\jon_doh@ddouglas.k12.or.us\restored.mbox".

If it still doesn't work, check the contents of the log file (import-mbox-to-gmail.log), and share it here (with a screenshot of any errors you're seeing in the commandline). Please make sure it doesn't include any private information, of course (such as the JSON file contents, etc.).

Hi guys,

if you type "c:\ more import-mbox-to-gmail.log

that should display the contents of the error log another method would be to remove everything after the --replaceqp so your command would look like this

mbox-to-gmail.py --json c:\mbox\GmailRestore-605fbe12b095.json --dir
c:\mbox\jon_doh@ddouglas.k12.or.us --replaceqp

commented

log file contents

'import-mbox-to-gmail.py' is not recognized as an internal or external command,
operable program or batch file.

Make sure you run the command from inside the importer directory see attached:

screenshot from 2016-02-11 11-51-19

  1. Make sure that you closed the Command Prompt window and opened a new one after installing Python. Otherwise, it won't recognize Python scripts.
  2. If it still doesn't work, try adding "python" in the beginning, e.g. instead of "import-mbox-to-gmail.py ..." use "python import-mbox-to-gmail.py ...".
  3. If that doesn't work either, try the full python.exe path, e.g. "C:\Python27\python.exe import-mbox-to-gmail.py ..."
commented

Boom! Got it!
Here are the issues I had to resolve:

  1. I had not created an "importer" file containing the import-mailbox-to-gmail.py as seen in the directory structure above
  2. Did a "save link as..." out of the browser for the .py file. Had to go back and copy the raw text into the .py file to get rid of HTML language in the save
  3. The command calls for "import-mbox-to-gmail.py" but the correct name is "import-mailbox-to-gmail.py"
  4. Adding C:\Python27\python.exe to the beginning of the command line was necessary.

Final working command:
C:\Python27\python.exe import-mailbox-to-gmail.py --json c:\importer\GmailRestore.json --dir c:\mbox\ --replaceqp >> import-mbox-to-gmail.log 2>&1

Thanks for everyones input. Makes my life a whole lot easier not having to restore user emails using Thunderbird.

Thank you everyone for all the detailed steps. I am following them and will post back with an update about how it went for me.

I updated the instructions based on your feedback - thanks! If you still encounter any issues please reopen this issue.

I followed all the above steps. Now, after running the command, the cursor is blinking. Does that mean that it is in the process of importing?

Also, see I the folder named "Imported Messages" inside my gmail account. But, there are no messages in it.

If the cursor is blinking it means it's running, yes. You should be able to see progress in the log (import-mbox-to-gmail.log).

If no messages are being imported, can you check for any errors/exceptions in the log?

I am getting these errors HttpError 400 and HttpAccessTokenRefreshError

For both errors, they should appear with some more context that would tell you why it failed.

Example for HttpError 400:
HttpError: <HttpError 400 when requesting https://www.googleapis.com/upload/gmail/v1/users/user%40domain.com/messages/import?internalDateSource=dateHeader&neverMarkSpam=true&fields=id&uploadType=multipart&processForCalendar=false&alt=json returned "Invalid From header">

In this case, the reason it failed is an invalid From header. To find which message you need to fix, look for a line above the error that say something like Processing message 2 in label 'INBOX', this will tell you which message in which mbox file failed.

Example for HttpAccessTokenRefreshError:
HttpAccessTokenRefreshError: invalid_grant: Not a valid email.

In this case, the reason it failed is that the email address isn't valid (doesn't exist).

If you've encountered different errors from these, please paste the full error text here and I'll take a look.

Thanks!

Thanks. I will try the process again.

I'm also having trouble with the last step. (Running on a Mac.)

My command is:

/Users/VG/Downloads/import-mailbox-to-gmail.py --json /Users/VG/Downloads/Gmail API-[INFO DELETED].json --dir /Users/VG/Desktop/mbox

And the log error is:

-bash: /Users/VG/Downloads/import-mailbox-to-gmail.py: Permission denied

I've tried running the first bit as in the README (./import-mailbox.... at the start) and tweaking other bits inc. file permissions, but with no success.

Any help greatly appreciated. Thanks.

Try running it with:
python /Users/VG/Downloads/import-mailbox-to-gmail.py --json /Users/VG/Downloads/Gmail API-[INFO DELETED].json --dir /Users/VG/Desktop/mbox

i.e. add python in the beginning.

i contacted liron (the script author) and the README has been changed to fix this

Fixed in commit 531e4ae.