Restore (using version 0.45) dies with "400: Invalid label name - invalidArgument"

925 views
Skip to first unread message

Alastair

unread,
Apr 30, 2016, 1:36:10 PM4/30/16
to Got Your Back: Gmail Backup
Hi all

My restore has died with the "400: Invalid label name - invalidArgument" error, even though this issue was fixed in the current version of GYB I'm using (0.45).

I used the --debug option to log the error to a file, and it seems like it's choking on an "Inbox" label, which seems strange.

Any advice to allow me to continue the restore process would be greatly appreciated.

Cheers!
Alastair

Stéphane Martin

unread,
Jun 7, 2016, 5:13:55 AM6/7/16
to Got Your Back: Gmail Backup
Good morning Alastair,

I have the same issue using the latest version 0.47. According to the following entry the issue should be closed but isn't.

Best regards

Stéphane

Alastair

unread,
Jun 20, 2016, 7:52:39 AM6/20/16
to Got Your Back: Gmail Backup
Hi Stéphane

Yes, unfortunately the issue still crops up now and again. After trying unsuccessfully to obtain any feedback on this, I managed to resolve it myself.

The issue is caused by labels that Gmail rejects. In my case, these were all badly named labels in the client's data I was migrating, and all involved '/' in some way (hierarchical labels).

So I ran the restore command adding --debug > label-failure-output.txt to the end. I then inspected that file to see what it was choking on. I then searched the labels table in the GYB SQLite database for the offending label, using a command similar to 
SELECT distinct label FROM labels where label like '%inbox%' 
if for example Gmail was complaining about the label 'inbox'.
This usually turned up a few labels, and it would usually be clear which one was the issue - in my case a label like 'Inbox/Something'.
I then ran a command on the database (after backing it up just in case) similar to

UPDATE labels SET label = 'INBOX/Something' where label = 'Inbox/Something'

renaming the label by uppercasing it or adding an underscore before it, etc.

I then ran the restore command again and it would move past the email.


It helps to log into the restore destination Gmail account and inspect the label list if you hit an issue. You may be able to see a label assigned to 0 messages - which helps to track down or confirm the label name causing the issues.

It's worth noting that I also has issues with labels that weren't reserved Gmail labels, but were badly named with spaces, such as 'Stuff/More Stuff /things'. (Which I renamed to 'Stuff/More Stuff/things' in the database.)


Hope this helps yourself or others!

Cheers
Alastair

Stéphane Martin

unread,
Jun 21, 2016, 1:13:39 AM6/21/16
to got-yo...@googlegroups.com
Good morning Alastair,

first of all thanks a lot for your very detailed and helpful answer. I have checked your feedback and have decided to stop the GYB attempt and go for the Google Takeout approach.

Viele Grüße

Stéphane Martin
Director of Information Technology

Tel.: +49 (0) 6146 9090 300  I Mobil: +49 (0) 175 225 47 92
E-Mail: stephan...@hotelbb.com  I  Web: www.hotelbb.de


B&B HOTELS GmbH I Altkönigstr. 10 I D-65239 Hochheim am Main
Geschäftsführer: Georges Sampeur, Mark Thompson I Sitz: Hochheim am Main I Amtsgericht Wiesbaden: HRB 22103


--
--
You received this message because you are subscribed to the Google
Groups "Got Your Back: Gmail Backup" group.
To post to this group, send email to got-yo...@googlegroups.com
To unsubscribe from this group, send email to
got-your-bac...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/got-your-back?hl=en?hl=en

---
You received this message because you are subscribed to the Google Groups "Got Your Back: Gmail Backup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to got-your-bac...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

--
Mit freundlichen Grüßen / Best regards

Stéphane Martin
Director of Information Technology

B & B HOTELS GmbH
Altkönigstr. 10

65239 Hochheim am Main

Telefon: +49 (0) 6146 9090 300
Mobil: +49 (0) 175 225 4792

E-Mail: stephan...@hotelbb.com
Internet: http://www.hotelbb.de

Sitz: Hochheim am Main, Amtsgericht Wiesbaden: HRB 22103, Geschäftsführer:
Georges
Sampeur, Mark Thompson

Brett Carver

unread,
Jun 21, 2016, 1:20:39 AM6/21/16
to got-yo...@googlegroups.com
On Mon, Jun 20, 2016 at 10:13 PM, Stéphane Martin <stephan...@hotelbb.com> wrote:
and have decided to stop the GYB attempt and go for the Google Takeout approach.

Just be aware that Google Takeout is an archive utility, NOT a backup/restore utility.   Google Takeout does not support the restoring of previously archived data.  You can not restore a Gmail Takeout file back to Gmail again.

There are some workaround using GYB (suprise) or an e-mail client.  But you will not find a restore or import function in Google Takeout itself.

Stéphane Martin

unread,
Jun 21, 2016, 1:46:39 AM6/21/16
to got-yo...@googlegroups.com
Good morning Brett,

thanks for this clarification. I thought that I could restore parts of the mailbox using Thunderbird and the saved mbox files. Am I wrong?
--

Brett Carver

unread,
Jun 21, 2016, 1:49:51 AM6/21/16
to got-yo...@googlegroups.com
On Mon, Jun 20, 2016 at 10:46 PM, Stéphane Martin <stephan...@hotelbb.com> wrote:
I thought that I could restore parts of the mailbox using Thunderbird and the saved mbox files.

Yes, if Thunderbird can read an mbox file, you should be able to use it to move the messages into a Gmail account.  That's basically one of the workarounds I mentioned and should work fine.


--bkc

Steve Schupp

unread,
Sep 19, 2016, 12:39:59 PM9/19/16
to Got Your Back: Gmail Backup
I ran into this label error issue also: "400: Invalid label name - invalidArgument"

I was able to fix it with some info from the forums, the wiki and a bit of digging around.
Just thought I would post the steps I used, to fill in a few blanks in info when I was trying to solve this myself.



First I had to capture a debug log: python3 gyb.py --email your_a...@gmail.com --action restore  --debug > label-failure-output.txt

When looked at the label-failure-output.txt file, i noticed this:
send: b'{"name": "Inbox"}'
reply: 'HTTP/1.1 400 Bad Request\r\n'

Using Alistair's suggestions above, i did the following (this was on linux):
cd GYB-GMail-Backup-your_address@gmail
sqlite3 msg-db.sqlite
SELECT distinct label FROM labels where label like '%inbox%';

output will show your labels, mine looked like:
INBOX
Inbox/EMT
Inbox/EMT/Shanghai
Inbox/EMT/Shandong

I then renamed the 'Inbox' labels to INBOX_old:
UPDATE labels SET label = 'INBOX_old/EMT' where label = 'Inbox/EMT';
UPDATE labels SET label = 'INBOX_old/EMT/Shanghai' where label = 'Inbox/EMT/Shanghai';
UPDATE labels SET label = 'INBOX_old/EMT/Shandong' where label = 'Inbox/EMT/Shandong';

ctl-d 
to exit sqlite3

I then re-ran the restore without errors:
python3 gyb.py --email your_a...@gmail.com --action restore


Good luck! :)
Steve


Daniel Allen

unread,
Dec 31, 2016, 10:40:22 AM12/31/16
to Got Your Back: Gmail Backup
Steve, thank you for this helpful walk-through. It got me 99% to a complete solution. 

The one thing I had to do afterward was resolve a "409: Label name exists or conflicts - aborted" error, which I did within the new gmail account interface by deleting the errant label ("Migrated/sent-mail"), which had 0 conversations.

Best,
Daniel
Reply all
Reply to author
Forward
0 new messages