Code Monkey home page Code Monkey logo

got-your-back's Introduction

GYB

Got Your Back (GYB) is a command line tool for backing up your Gmail messages to your local computer. It uses Gmail's API over HTTPS.

Build Status

Quick Start

Linux / MacOS

Open a terminal and run:

bash <(curl -s -S -L https://gyb-shortn.jaylee.us/gyb-install)

this will download GYB, install it and start setup.

Windows

Download the MSI Installer from the GitHub Releases page. Install the MSI and you'll be prompted to setup GYB.

Downloads

You can download the current GYB release from the GitHub Releases page.

Documentation

The GYB documentation is hosted in the GitHub Wiki

Mailing List / Discussion group

The GYB mailing list / discussion group is hosted on Google Groups. You can join the list and interact via email, or just post from the web itself.

Author

GYB is maintained by Jay Lee. Please direct "how do I?" questions to Google Groups.

got-your-back's People

Contributors

adamci avatar arielancry avatar bewinxed avatar billdenney avatar csabapalfi avatar daethnir avatar eesheesh avatar eyereturn avatar jay-eleven avatar jay0lee avatar marwatk avatar mhrivnak avatar mystix avatar pmcgaley avatar rduplain avatar ribbons avatar tnachen avatar zepheiryan avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

got-your-back's Issues

running gyb for the first time

Typing "gyb --email [email protected] --action estimate" to run for the first time results in the error message "'gyb' is not recognized as an internal or external command, operable program, or batch file."

No more able to backup/fetch mails after restore

I did initially a backup of my mails which worked fine:
python ./gyb.py --email [email protected] --action backup --local-folder ./backup_local

To test the restore feature, I deleted 2 emails (from inbox and then from the trash) and then started the restore procedure:
python ./gyb.py --email [email protected] --action restore --local-folder ./backup_local

This seemed to work - it took a while and showed some logs which indicated that all mails were uploaded (not only 2).

I did not really see, that the mails I deleted before were restored properly, as they did not appear in the all mail view.

When I try to fetch mail again with
python ./gyb.py --email [email protected] --action backup --local-folder ./backup_local
I get following error message:

Using backup folder ./backup_local
Using folder [Gmail]/All Mail
GYB needs to examine 124 messages
GYB already has a backup of 0 messages
GYB needs to backup 124 messages
Traceback (most recent call last):
  File "./gyb.py", line 1323, in <module>
    main(sys.argv[1:])
  File "./gyb.py", line 742, in main
    (message_num, label))
sqlite3.IntegrityError: UNIQUE constraint failed: labels.message_num, labels.label

If I retry to restore it looks as it would do nothing:

python ./gyb.py  --email   [email protected]  --action restore --local-folder ./backup_local

Using backup folder ./old/backup_simon
using IMAP folder [Gmail]/All Mail

Error when restoring folders to new account

I am having difficulty transferring folders from local folder to new email account
OS: Windows 07
C:\gyb>gyb --email [email] --action restore --local-folder "[folder label]"
Using backup folder [folder label]
using IMAP folder [Gmail]/All Mail
restoring message 1 of [number] from [eml file]
error retrieving uid: [' [APPENDUID 11 17581] [THROTTLED]']: retrying...
Traceback :
File "gyb.py", line 1323, in
File "gyb.py", line 911, in main
UnboundLocalError: local variable 'restored_uid' referenced before assignment

GYB prints "killed" then quits after a couple of minutes of running backup on Linux

I am running the following command:
/usr/bin/python /backup/email/got-your-back-0.30/gyb.py --debug --email [email protected] --service-account [email protected] --local-folder /backup/email/[email protected]

I've tried running in debug but there doesn't appear to be anything useful, here are the last 10 lines.

46:50.29 < * 11499 FETCH (X-GM-LABELS ("\Important" "\Inbox") UID 11503 INTERNALDATE "21-Jul-2011 07:44:49 +0000" FLAGS (\Seen) BODY[] {31819}
46:50.29 read literal size 31819
46:50.45 < )
46:50.45 < * 11500 FETCH (X-GM-LABELS ("\Important" "\Inbox") UID 11504 INTERNALDATE "21-Jul-2011 07:54:58 +0000" FLAGS (\Seen) BODY[] {15148965}
46:50.45 read literal size 15148965
46:52.41 < )
46:52.41 < CLIP8 OK Success
Killed

oauth2 errors when running bulk operations

I'm setting this up to purge infected or phishing emails that are bulk-sent to our users. I have a script that runs the purge command using my service account, pulling the necessary variables from a CSV. The issue is that it works fine if the CSV is small (lets say, 5 infected users, and thus 5 lines). But as soon as it starts getting bigger, it randomly throws errors for more than half for "invalid _grant" and "unauthorized_client". Do I have something misconfigured?

!/bin/bash

INPUT=/home/chris/Desktop/currentversion.csv
cd ~/gyb

OLDIFS=$IFS
IFS=,
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }

while read -r MessageID Recipientaddress
do

python gyb.py --service-account [email protected] --search "rfc822msgid:$MessageID" --action purge --email $Recipientaddress

done < $INPUT
IFS=$OLDIFS

Traceback (most recent call last):
File "gyb.py", line 1323, in
main(sys.argv[1:])
File "gyb.py", line 575, in main
imapconn = gimaplib.ImapConnect(generateXOAuthString(options.email, options.service_account), options.debug)
File "gyb.py", line 269, in generateXOAuthString
service = apiclient.discovery.build('oauth2', 'v2', http=http)
File "/home/chris/gyb/oauth2client/util.py", line 128, in positional_wrapper
return wrapped(_args, *_kwargs)
File "/home/chris/gyb/apiclient/discovery.py", line 192, in build
resp, content = http.request(requested_url)
File "/home/chris/gyb/oauth2client/util.py", line 128, in positional_wrapper
return wrapped(_args, *_kwargs)
File "/home/chris/gyb/oauth2client/client.py", line 475, in new_request
self._refresh(request_orig)
File "/home/chris/gyb/oauth2client/client.py", line 653, in _refresh
self._do_refresh_request(http_request)
File "/home/chris/gyb/oauth2client/client.py", line 710, in _do_refresh_request
raise AccessTokenRefreshError(error_msg)
oauth2client.client.AccessTokenRefreshError: unauthorized_client
Traceback (most recent call last):
File "gyb.py", line 1323, in
main(sys.argv[1:])
File "gyb.py", line 575, in main
imapconn = gimaplib.ImapConnect(generateXOAuthString(options.email, options.service_account), options.debug)
File "gyb.py", line 269, in generateXOAuthString
service = apiclient.discovery.build('oauth2', 'v2', http=http)
File "/home/chris/gyb/oauth2client/util.py", line 128, in positional_wrapper
return wrapped(_args, *_kwargs)
File "/home/chris/gyb/apiclient/discovery.py", line 192, in build
resp, content = http.request(requested_url)
File "/home/chris/gyb/oauth2client/util.py", line 128, in positional_wrapper
return wrapped(_args, *_kwargs)
File "/home/chris/gyb/oauth2client/client.py", line 475, in new_request
self._refresh(request_orig)
File "/home/chris/gyb/oauth2client/client.py", line 653, in _refresh
self._do_refresh_request(http_request)
File "/home/chris/gyb/oauth2client/client.py", line 710, in _do_refresh_request
raise AccessTokenRefreshError(error_msg)
oauth2client.client.AccessTokenRefreshError: invalid_grant

Group email size limit

I am getting this error while uploading to the group : line 665, in method
raise MediaUploadSizeError("Media larger than: %s" % maxSize)
apiclient.errors.MediaUploadSizeError: Media larger than: 16777216

I have read on google's group support page : Yes, the maximum size limit for messages sent to a group is 25 MB, including attachments (the normal Gmail limit). (https://support.google.com/a/answer/167085?hl=en) . How can I change this?

Use of Service account failing with traceback.

Running a backup using a service account fails as can be seen below. (This worked fine on versions older than 0.29.)
This from 0.31 on Python 2.7.10.

"/usr/bin/python2.7 gyb.py --email [email protected] --action backup --service-account [email protected]"

Traceback (most recent call last):
File "gyb.py", line 1333, in
main(sys.argv[1:])
File "gyb.py", line 578, in main
imapconn = gimaplib.ImapConnect(generateXOAuthString(options.email, options.service_account), options.debug)
File "gyb.py", line 268, in generateXOAuthString
credentials = oauth2client.client.SignedJwtAssertionCredentials(service_account_name=service_account_name, private_key=key, scope=scope, user_agent=getGYBVersion(' / '), prn=email)
AttributeError: 'module' object has no attribute 'SignedJwtAssertionCredentials'

Error with --service-account

Hi,

when I try to run an estimate with the --service-account option I receive the following error:

Traceback (most recent call last):
File "gyb.py", line 1317, in
main(sys.argv[1:])
File "gyb.py", line 572, in main
imapconn = gimaplib.ImapConnect(generateXOAuthString(options.email, options.service_account), options.debug)
File "gyb.py", line 269, in generateXOAuthString
service = apiclient.discovery.build('oauth2', 'v2', http=http)
File "/google/gyb/oauth2client/util.py", line 128, in positional_wrapper
return wrapped(_args, *_kwargs)
File "/google/gyb/apiclient/discovery.py", line 192, in build
resp, content = http.request(requested_url)
File "/google/gyb/oauth2client/util.py", line 128, in positional_wrapper
return wrapped(_args, *_kwargs)
File "/google/gyb/oauth2client/client.py", line 475, in new_request
self._refresh(request_orig)
File "/google/gyb/oauth2client/client.py", line 653, in _refresh
self._do_refresh_request(http_request)
File "/google/gyb/oauth2client/client.py", line 677, in _do_refresh_request
body = self._generate_refresh_request_body()
File "/google/gyb/oauth2client/client.py", line 861, in _generate_refresh_request_body
assertion = self._generate_assertion()
File "/google/gyb/oauth2client/client.py", line 977, in _generate_assertion
private_key, self.private_key_password), payload)
File "/google/gyb/oauth2client/crypt.py", line 131, in from_string
pkey = crypto.load_pkcs12(key, password).get_privatekey()
File "/home/re/.local/lib/python2.7/site-packages/pyOpenSSL-0.14-py2.7.egg/OpenSSL/crypto.py", line 2216, in load_pkcs12
_raise_current_error()
File "/home/re/.local/lib/python2.7/site-packages/pyOpenSSL-0.14-py2.7.egg/OpenSSL/_util.py", line 22, in exception_from_error_queue
raise exceptionType(errors)
OpenSSL.crypto.Error: [('asn1 encoding routines', 'ASN1_CHECK_TLEN', 'wrong tag'), ('asn1 encoding routines', 'ASN1_ITEM_EX_D2I', 'nested asn1 error')]

There is an API project created following your howto, privatekey.p12 is in place.
OS: Ubuntu 12.04.
Python 2.7.3

Help much appreciated!
Cheers,
Ben

Whitespaces in labels throwing error.

Dear gyb Team
Whitespaces in labels throwing undiscripted error.
Kindly adjust code to allow labels with whitespaces too, if feasible. or at least add proper error description, so that users can easily understand fix the error.

Fails to restore MBOX file

The restore ran for quite some time then it died. Now everytime I go to run it I am getting the same error.

Here is the error with debug

5-29-2015 11-50-16 am

Issue performing a backup from the Google Apps Business and Education Admins

Ok so I followed the directions in the wiki located here and got this error in the terminal:

Traceback (most recent call last):
File "gyb.py", line 1323, in
main(sys.argv[1:])
File "gyb.py", line 575, in main
imapconn = gimaplib.ImapConnect(generateXOAuthString(options.email, options.service_account), options.debug)
File "gyb.py", line 261, in generateXOAuthString
credentials = oauth2client.client.SignedJwtAssertionCredentials(service_account_name=service_account, private_key=key, scope=scope, user_agent=getGYBVersion(' / '), prn=email)
AttributeError: 'module' object has no attribute 'SignedJwtAssertionCredentials'

Any thoughts on this? I have looked around a bit and don't know where to go from here.

Thanks
B

NameError: name 'sqlcur' is not defined

Get error:
NameError: name 'sqlcur' is not defined when running "--action estimate" for first time.

Select the actions you wish GYB to be able to perform for XXXXXXX

[ ] 0) Gmail Backup And Restore - read/write mailbox access
[*] 1) Gmail Backup Only - read-only mailbox access
[ ] 2) Gmail Restore Only - write-only mailbox access and label management
[ ] 3) Gmail Full Access - read/write mailbox access and message purge
[ ] 4) No Gmail Access

[ ] 5) Groups Restore - write to Google Apps Groups Archive
[*] 6) Storage Quota - Drive app config scope used for --action quota

  7)  Continue

7
Go to the following link in your browser:

https://goo.gl/lFYMGa

Enter verification code: XXXXXXXXX
Authentication successful.
Got 195582 Message IDs
GYB needs to examine 195582 messages
Traceback (most recent call last):
File "gyb.py", line 1491, in
main(sys.argv[1:])
File "gyb.py", line 1454, in main
if not newDB and message_is_backed_up(message_num['id'], sqlcur,
NameError: name 'sqlcur' is not defined

Restore process is very slow

I need to restore email(google apps) with 7k emails. It works fine, but takes about 10 hours. It's very slow for 1.3 GB of data. Backup process of this email is much faster.

shebang line broken on unix in gyb.py

gyb.py starts with

!/usr/bin/env python-

This should be

!/usr/bin/env python

unless you really excpect all unix distros to have a binary "python-".

Cannot find the Gmail "All Mail" folder

It would seem that from today there have been some changes to how Gmail names the folders. The script now tells me that it cannot find the "All Mail" folder and if I run the script with --debug I get the following:

 55:38.45 > NDGC4 LIST "[Gmail]/" *
  55:38.51 < NDGC4 OK Success
  55:38.51 > NDGC5 LIST "[Google Mail]/" *
  55:38.54 < * LIST (\All \HasNoChildren) "/" "[Google Mail]/All Mail"
  55:38.54 < * LIST (\HasNoChildren \Trash) "/" "[Google Mail]/Bin"
  55:38.54 < * LIST (\Drafts \HasNoChildren) "/" "[Google Mail]/Drafts"
  55:38.54 < * LIST (\Important \HasNoChildren) "/" "[Google Mail]/Important"
  55:38.54 < * LIST (\Sent \HasNoChildren) "/" "[Google Mail]/Sent Mail"
  55:38.54 < * LIST (\Junk \HasNoChildren) "/" "[Google Mail]/Spam"
  55:38.54 < * LIST (\HasNoChildren \Flagged) "/" "[Google Mail]/Starred"
  55:38.54 < NDGC5 OK Success

OpenSSL Error Opening privatekey.p12

After following the instructions for using Service accounts I get the following error when trying to execute the --action estimate command:

OpenSSL.crypto.Error: [('asn1 encoding routines', 'ASN1_CHECK_TLEN', 'wrong tag'), ('asn1 encoding routines', 'ASN1_ITEM_EX_D2I', 'nested asn1 error')]

Installation under CentOS

Hi,

I've tried to use GYB on a CentOS 6.6 and encountered some errors. I thought I share my solutions maybe someone will benefit from them.

Error:
'module' object has no attribute 'SignedJwtAssertionCredentials'

Solution:
You have to install pyOpenSSL and python-crypto2.6 (I'm using python 2.6)

The pyOpenSSL rpm prvovided by CentOS base repo is currently v0.10 which is not enough
because then it will produce another similar error:
'module' object has no attribute 'sign'

So you have to install a more recent version. I've used pip to install like this:
yum install python-pip

You'll need to install
yum install python-devel openssl-devel libffi-devel

Then
pip install pyopenssl

And now it's working like a charm.

Happy backup :)

Error with label name when restoring to new account

File "gyb.py", line 1323, in
main(sys.argv[1:])
File "gyb.py", line 911, in main
r, d = imapconn.uid('STORE', restored_uid, '+X-GM-LABELS', labels_string)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/imaplib.py", line 760, in uid
typ, dat = self._simple_command(name, command, *args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/imaplib.py", line 1070, in _simple_command
return self._command_complete(name, self._command(name, *args))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/imaplib.py", line 905, in _command_complete
raise self.error('%s command error: %s %s' % (name, typ, data))
imaplib.error: UID command error: BAD ['Invalid Arguments: Label name is not allowed: TODO']

I will try to work around this error by renaming that label in source acct and then backing up again but I wonder if there are other "forbidden" labels?

Server responded with NO ['System Error (Failure)']

Hello jay0lee,

I'm having an issue with using gyb. Whenever I backup email from a users account it works successfully for some time. It will eventually be unable to continue. I tried deleting the backup folder and start it over but it always stops at around the same point. I tried service account and logging into the account to back up and neither one worked successfully. It seems like it stops after 10k-13k emails.

Here's the log:

Using backup folder [email protected]
Using folder [Gmail]/All Mail
GYB needs to examine 16304 messages
GYB already has a backup of 0 messages
GYB needs to backup 16304 messages
backed up 10500 of 16304 messages
Server responded with NO ['System Error (Failure)'], will retry in 2.0 secondbacked up 11200 of 16304 messages
Server responded with NO ['System Error (Failure)'], will retry in 2.0 seconds
Server responded with NO ['System Error (Failure)'], will retry in 4.0 seconds
Server responded with NO ['System Error (Failure)'], will retry in 8.0 seconds
Server responded with NO ['System Error (Failure)'], will retry in 16.0 seconds
Server responded with NO ['System Error (Failure)'], will retry in 32.0 seconds
Server responded with NO ['System Error (Failure)'], will retry in 64.0 seconds
Server responded with NO ['System Error (Failure)'], will retry in 128.0 seconds
Error: failed to retrieve messages.
NO ['System Error (Failure)']

Restore Challenge

I was presented with a bunch of mbox files as part of a recent acquisition. Not sure how they were created (not with GYB). They do not have a *.sqlite database file. Is there any way to restore these to mailboxes with GYB?

backup with --search and default labels renamed after restor !!

Hi All,

From GYB 0.31 under Windows 7, the backup from search return inconsistent response, even not close to what exist. So I decided to test the Linux version under Ubuntu 14.04.02 LTS and surprise the backup with search and restore works like a charm ! I guess there is something with the Python version on the Windows release..?
BUT !! nothing is smooth at least for me .. after restoring a full version (from GMail/All Mail) I was very surprise to find that the basic labels (Inbox, Draft, etc.) stay empty and that new labels instead are created and use as the default system folders, they look like: "\Inbox", "\Draft" etc...
I even cannot move the mails manually from there to the original Inbox !!
I don't know if Google has again changed something but I would be very happy if someone could help..

Many Thanks,
Jo

error while using the script

OS: windows 7
C:\gyb>gyb --email @gmail.com --action estimate
Traceback (most recent call last):
File "gyb.py", line 1317, in
File "gyb.py", line 572, in main
File "gimaplib.pyo", line 47, in ImapConnect
File "imaplib.pyo", line 1148, in init
File "imaplib.pyo", line 163, in init
File "imaplib.pyo", line 1159, in open
File "socket.pyo", line 571, in create_connection
socket.error: [Errno 10060] A connection attempt failed because the connected pa
rty did not properly respond after a period of time, or established connection f
ailed because connected host has failed to respond

C:\gyb>gyb --email @gmail.com --action backup
Traceback (most recent call last):
File "gyb.py", line 1317, in
File "gyb.py", line 572, in main
File "gimaplib.pyo", line 47, in ImapConnect
File "imaplib.pyo", line 1148, in init
File "imaplib.pyo", line 163, in init
File "imaplib.pyo", line 1159, in open
File "socket.pyo", line 571, in create_connection
socket.error: [Errno 10060] A connection attempt failed because the connected pa
rty did not properly respond after a period of time, or established connection f
ailed because connected host has failed to respond

Service Account Client ID not appearing on Google Developer Page

When using the Google Apps for business directions

https://github.com/jay0lee/got-your-back/wiki#google-apps-business-and-education-admins-backup-restore-and-estimate-users-and-restore-to-groups

Step 12 says to record the client ID (used later in step 19), but this information is not available on the credentials page in the developer console, only an email address and a certificate fingerprint (neither of which work as an ID for API client access) Any thoughts on how to get this ID?

Thanks,
B

Daily Limit issue

Hi i am trying to upload mbox emails and having the following issue

Traceback (most recent call last):
File "gyb.py", line 1323, in
main(sys.argv[1:])
File "gyb.py", line 560, in main
requestOAuthAccess(auth_as, options.debug)
File "gyb.py", line 204, in requestOAuthAccess
credentials = oauth2client.tools.run(FLOW, storage, short_url=True, http=http)
File "/usr/local/google/home/vmk/Downloads/got-your-back-0.29/oauth2client/util.py", line 128, in positional_wrapper
return wrapped(_args, *_kwargs)
File "/usr/local/google/home/vmk/Downloads/got-your-back-0.29/oauth2client/tools.py", line 169, in run
url_result = service.url().insert(body={'longUrl': authorize_url}).execute()
File "/usr/local/google/home/vmk/Downloads/got-your-back-0.29/oauth2client/util.py", line 128, in positional_wrapper
return wrapped(_args, *_kwargs)
File "/usr/local/google/home/vmk/Downloads/got-your-back-0.29/apiclient/http.py", line 680, in execute
raise HttpError(resp, content, uri=self.uri)
apiclient.errors.HttpError: <HttpError 403 when requesting https://www.googleapis.com/urlshortener/v1/url?alt=json returned "Daily Limit for Unauthenticated Use Exceeded. Continued use requires signup.">

Imap errors while restoring

Hi,
First I'd like to thank you for having set this application up. It is really a strait forward solution I have seen.
I am actually doing a restore to a new account as follow:
gyb --email [email protected] --action restore [email protected]

I am using:

  • Win7 - SP1
  • GYB version 0.31
  • Python 2.7.10 64-bit final

Here are the latest messages while restoring (it has already failed twice since 2 days):
Using backup folder [email protected]
using IMAP folder [Gmail]/all messages
restoring message 3712 of 48522 from 2014\12\11-2408.emll
imaplib.abort error:command: APPEND => System Error, retrying...
restoring message 4400 of 48522 from 2014\12\11\11-1490.eml
imaplib.abort error:command: APPEND => System Error, retrying...
restoring message 7281 of 48522 from 2014\9\8\11-47064.emlll
imaplib.abort error:command: APPEND => socket error: EOF, retrying...
restoring message 7542 of 48522 from 2014\8\298\11-46778.eml
imaplib.abort error:command: APPEND => socket error: EOF, retrying...
restoring message 28197 of 48522 from 2013\1\22\11-26017.emll

the last line keep incrementing but I am not sure why I receive those errors and if all is correctly restored. I think it is also impacting the restore performances.

Many Thanks for your advises and help

setup.py py2exe error on Mac Yosemite

I am working on a Mac, Yosemite version.
When I run setup.py install, I'm getting this error:

File "setup.py", line 2, in <module>
import py2exe, sys, os
ImportError: No module named py2exe

Isn't py2exe for Windows only?
How can I get past this?

Fails to restore from mbox to group

I don't know if i'm doing something wrong or there is a bug. I grabbed a .mbox file from my gmail account (single label) and trying to upload it to a google group using GYB.
However it fails. It worked fine with a backup taken by GYB but with .mbox files it doesnt. I need to see if i can get the mbox upload to work as i'm migrating a bunch of shared folders and converting them to .mbox and uploading to groups using GYB would be the best way (almost only way atm).

this is what happens.

Nurv:got-your-back-0.29 bmk$ python gyb.py --email [email protected] --action restore-group --action restore-mbox --local-folder "./input/coding.mbox" --use-admin [email protected]
Traceback (most recent call last):
  File "gyb.py", line 1323, in <module>
    main(sys.argv[1:])
  File "gyb.py", line 575, in main
    imapconn = gimaplib.ImapConnect(generateXOAuthString(options.email, options.service_account), options.debug)
  File "/Users/bmk/Downloads/got-your-back-0.29/gimaplib.py", line 50, in ImapConnect
    imap_conn.authenticate('XOAUTH2', lambda x: xoauth_string)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/imaplib.py", line 351, in authenticate
    raise self.error(dat[-1])
imaplib.error: Lookup failed ru8mb72396831lbb

I have edited the above slightly in order to mask a bit of the details about domain ect. But both the admin user works, and the groups mail add is correct. And as said both work with a backup created by GYB but wha ti need is the ability to restore .mbox files into groups.

Error during mbox restore - AttributeError: 'NoneType' object has no attribute 'group'

During an mbox restore, I get these messages frequently. If I wait a few hours, the issue seems to go away by itself, but returns after a few dozen more messages are restored. Any ideas?

I'm using:

Got Your Back 0.29
Jay Lee - [email protected]
Python 2.7.8 64-bit final
Windows-2008ServerR2-6.1.7601-SP1 AMD64

Restoring from h:\[email protected]_0.mbox
message 1 of 175Traceback (most recent call last):
File "gyb.py", line 1323, in
File "gyb.py", line 1033, in main
AttributeError: 'NoneType' object has no attribute 'group'

Fails to restore from mbox

HI,

I am trying to move my e-mail (from claws client) to gmail. I have exported an mbox from
claws and now want to import it to gmail. When I do this

python ./gyb.py --email *****@gmail.com --action restore-mbox --local-folder inbox_claws --label-restored "F"

I get the following error message

 Using backup folder inbox_claws
 Traceback (most recent call last):
   File "./gyb.py", line 1323, in <module>
     main(sys.argv[1:])
   File "./gyb.py", line 601, in main
     sqlconn = sqlite3.connect(sqldbfile, detect_types=sqlite3.PARSE_DECLTYPES)
 sqlite3.OperationalError: unable to open database file

This is done from a Centos 6.0 server, but the same error was obtained also from
a Windows environment.

Any idea to solve this?

regards,

adolfo

Running In Linux

Hi,
I had two issues when running it in Linux. Here are the errors with my temporary fixes:

Error # 1:

NameError: global name 'options' is not defined

Solution to # 1: Added

global options

on the line just after the start of the main declaration

Error # 2:

AttributeError: 'module' object has no attribute 'run_flow'

Solution to # 2: Swapped the commenting of the two lines you wrote so that the result is:

 credentials = oauth2client.tools.run(FLOW, storage, short_url=True, http=http)
 #credentials = oauth2client.tools.run_flow(flow=FLOW, storage=storage, flags=flags, http=http)

It seems like its running the backup now. Is there any chance I am doing something wrong when installing? I downloaded the zip file on the page. Thanks, this code is a great idea!

GYB version : 0.28
Python version : Python 2.7.6

Too many values to unpack

Getting this error pretty frequently this week:

  File "/mnt/nas/Backups/email/gyb/gyb.py", line 1011, in <module>
    main(sys.argv[1:])
  File "/mnt/nas/Backups/email/gyb/gyb.py", line 594, in main
    for everything_else_string, full_message in (x for x in d if x != ')'):
ValueError: too many values to unpack

Pulled most recent version and seeing the same issue:

$ python gyb.py --email [email protected] --service-account [email protected] --action backup --local-folder /mnt/nas/Backups/email/foo\@gmail.com/

Using backup folder /mnt/nas/Backups/email/[email protected]/
Using folder [Gmail]/All Mail
GYB needs to examine 70637 messages
GYB already has a backup of 70627 messages
GYB needs to backup 10 messages
Traceback (most recent call last):
  File "gyb.py", line 1473, in <module>
    main(sys.argv[1:])
  File "gyb.py", line 830, in main
    for everything_else_string, full_message in (x for x in d if x != ')'):
ValueError: too many values to unpack

EDIT to add version:

$ python gyb.py --version
Got Your Back 0.28
Jay Lee - [email protected]
Python 2.7.6 64-bit final
Linux-3.8.0-27-generic-x86_64-with-Ubuntu-14.04-trusty x86_64

Broken pipe on restore with gyb HEAD

Hi,

following error occures with an mbox-file that i try to push back to google. Seems there is "something" in there gyb or google don't like. Filesize maybe? This is an mbox-file from Google Vault, so I wonder why this seems to be incompatible in some way.

Is there a way how I can manually edit the mbox-file to get past this error?
If this is an error with one message, how about an option to drop this single message from recovery?

imaplib.abort error:socket error: [Errno 32] Broken pipe, retrying...
35:00.37 > OEFJ1 AUTHENTICATE XOAUTH2
35:00.42 < +
35:00.42 write literal size 160
35:00.75 < * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE ENABLE MOVE CONDSTORE ESEARCH UTF8=ACCEPT
35:00.75 < OEFJ1 OK [email protected] authenticated (Success)
35:00.75 > OEFJ2 CAPABILITY
35:00.90 < * CAPABILITY IMAP4rev1 UNSELECT IDLE NAMESPACE QUOTA ID XLIST CHILDREN X-GM-EXT-1 UIDPLUS COMPRESS=DEFLATE ENABLE MOVE CONDSTORE ESEARCH UTF8=ACCEPT
35:00.90 < OEFJ2 OK Success
35:00.90 > OEFJ3 ID ("name" "Got Your Back: Gmail Backup" "version" "0.30" "vendor" "Jay Lee" "contact" "[email protected]")
35:01.05 < * ID ("name" "GImap" "vendor" "Google, Inc." "support-url" "http://support.google.com/mail" "version" "gmail_imap_150512.06_p1" "remote-host" "94.198.xxx.xxx")
35:01.05 < OEFJ3 OK Success
35:01.05 > OEFJ4 SELECT "[Gmail]/Alle Nachrichten"
35:02.19 < * FLAGS (\Answered \Flagged \Draft \Deleted \Seen $Phishing $NotPhishing)
35:02.19 < * OK [PERMANENTFLAGS (\Answered \Flagged \Draft \Deleted \Seen $Phishing $NotPhishing *)] Flags permitted.
35:02.19 < * OK [UIDVALIDITY 11] UIDs valid.
35:02.19 < * 109343 EXISTS
35:02.19 < * 0 RECENT
35:02.19 < * OK [UIDNEXT 132575] Predicted next UID.
35:02.19 < * OK [HIGHESTMODSEQ 2349217]
35:02.19 < OEFJ4 OK [READ-WRITE] [Gmail]/Alle Nachrichten selected. (Success)
35:02.26 > OEFJ5 APPEND "[Gmail]/Alle Nachrichten" (\Seen) "12-Dec-2014 12:06:07 +0100" {5101070}
35:02.41 < + go ahead
35:02.41 write literal size 5101070

Regards
Ben

PKSC12 issue

I am running GYB on a windows 7 64bit pc. I downloaded and extracted gyb-0.30-windows-x64.zip. I followed the steps in the wiki to install and create the service account for my Google Apps for education account. I generated the P12 key and renamed it to privatekey.p12 as listed in the wiki. When I try to run a gyb command using the service account, I get the following error:
Traceback (most recent call last):
File "gyb.py", line 1323, in
File "gyb.py", line 575, in main
File "gyb.py", line 269, in generateXOAuthString
File "oauth2client\util.pyo", line 128, in positional_wrapper
File "apiclient\discovery.pyo", line 192, in build
File "oauth2client\util.pyo", line 128, in positional_wrapper
File "oauth2client\client.pyo", line 475, in new_request
File "oauth2client\client.pyo", line 653, in _refresh
File "oauth2client\client.pyo", line 677, in _do_refresh_request
File "oauth2client\client.pyo", line 861, in _generate_refresh_request_body
File "oauth2client\client.pyo", line 977, in _generate_assertion
File "oauth2client\crypt.pyo", line 237, in from_string
NotImplementedError: PKCS12 format is not supported by the PyCrpto library. Try
converting to a "PEM" (openssl pkcs12 -in xxxxx.p12 -nodes -nocerts > privatekey
.pem) or using PyOpenSSL if native code is an option.

Thanks For any insight on this issue.
Harold
PS. Version 0.20 Alpha was working fine.

SyntaxError: invalid syntax

When running latest version, I get this error, on both mac and linux (first run on machine).

python gyb.py --email [email protected] --action estimate
Traceback (most recent call last):
File "gyb.py", line 60, in
import httplib2
File "/Users/me/scripts/got-your-back-master/httplib2/init.py", line 352
print('%s:' % h, end=' ', file=self._fp)
^
SyntaxError: invalid syntax

Restore Group

Hi,

When I am trying to restore a group : python gyb.py --email [email protected] --action restore-group --use-admin [email protected] I am getting this error message : Created new window in existing browser session.
Authentication successful.
Error: you did not authorize the OAuth token in the browser with the [email protected] Google Account. Please make sure you are logged in to the correct account when authorizing the token in the browser.

I have also followed the Google Apps Business and Education Admins: Backup, Restore and Estimate Users and Restore to Groups setup. I am logging in to the [email protected] account, what I am doing wrong.

imaplib.error: UID command error: BAD ['Could not parse command']

I'm trying to run actions on a subset of all mails by using search criteria. The problem I'm facing is that these labels that I'm including in my search use NON-US characters like Č Š and Ž.

When I try to search mail using such label characters I get the error from the Subject.

I've tried percent/URL encoding but it doesn't help.

GYB gmail access failed after Google no longer supports OAuth 1.0

Dear Developer,

GYB has been my go to tool for backing up and migrating Gmail accounts. It has worked wonderfully. Thank you!

GYB recently stopped working (last automatic backup completed was on May 5). When it runs, GYB could not gain access (access was granted before when automatic backup was setup):
image

When GYB tries to open a browser page for user to grant GYB access to gmail, this page opens up:
https://support.google.com/a/answer/6224347?p=oauth&rd=1

It looks like Google has changed the authentication process from OAuth 1.0 to OAuth 2.0 (Why do these big companies always break things that work!?).

Could this be fixed soon?

Thanks so much for such a wonderful tool. I hope it could continue to benefit users.

Best regards,
lichen98

Restore begins working, then many UID command errors

_UPDATE_ NOW WORKING AFTER REMOVING "--label-restored' COMMAND

Hi there

Couldnt' find an answer to this one, running GYB on OSX 10.10.3, here is the run down:

  1. performed full GYB backup of old gmail account - SUCCESS
  2. performed full GYB backup of new gmail account - SUCCESS
  3. Begins restoring from old backup to new gmail starts well then - FAIL
    See below results

TelstraAA7T8F4S:gyb dg$ python gyb.py --email [email protected] --action restore --local-folder \[email protected] --label-restored “PORTED”

Using backup folder [email protected]
using IMAP folder [Gmail]/All Mail
restoring message 1 of 16053 from 2015/8/19/640547985-194683.emlTraceback (most recent call last):
File "gyb.py", line 1323, in
main(sys.argv[1:])
File "gyb.py", line 911, in main
r, d = imapconn.uid('STORE', restored_uid, '+X-GM-LABELS', labels_string)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/imaplib.py", line 760, in uid
typ, dat = self._simple_command(name, command, *args)
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/imaplib.py", line 1070, in _simple_command
return self._command_complete(name, self._command(name, *args))
File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/imaplib.py", line 905, in _command_complete
raise self.error('%s command error: %s %s' % (name, typ, data))
imaplib.error: UID command error: BAD ['Could not parse command']

Add a way to strip headers or HTML or both

My predicament

Currently I'm using GYB to download messages that match a certain search query, such as:

gyb --email [email protected] --action backup --search \
'((from:[email protected]||from:[email protected])||(to:[email protected]||from:[email protected]))' \ 
 --local-folder GYB-markov'

When creating continuous-time Markov chains using a Gmail search query, most headers and all HTML tags are very undesirable. If I don't strip all of the mail-headers and HTML tags first, I'd end up with sentences like:
The quick brown fox jumped over my crappy --Content-type=UTF-8. or,
X-SPF-Verdict is my favorite kind of soup.

Anyway, I propose one command line option:

--strip <none|html|headers|all>

When using the --backup option, remove some content from the message after it's been backed-up.
If --format is missing, --format strip-none is implied.

none

Do not remove any HTML tags, message headers, or anything.

html

Only removes HTML tags from messages after backup. Nothing else.

all

Strip absolutely everything. This includes all headers, and all HTML tags.

Notes

  • This might involve adding a dependency upon BeautifulSoup or something.
  • --strip all is the implied default.
    Actually implementing this may be done by either "stripping first, saving later," or "save first, strip in place." My guess (just a hunch), is that the latter would be more secure and require less memory.

P.S.

I really love this project. Thanks for all you do!! ❤️.

Problem Setting up GYB Service Account

I am trying to setup a service account to use with GYB, and the instructions point me to enable the "Groups Migration API", but the API listing has changed completely in the Google Developers Console. I do not see this API listed.

Which API should I enable? I have this setup for another Google Apps for Education domain whe that API appeared in the old listing in the Dev Console.
The Google Apps APIs I can choose from are:
Drive API
Drive SDK
Calendar API
Gmail API
Google Apps Marketplace SDK
Admin SDK
Contacts API
CalDAV API

Any ideas?

GYB not creating backup folder or files. No error.

I followed the Wiki and everything looks like it works but the folder is empty. I tried with the defaults so GYB would make it's own folder but it doesn't exist after doing it that way either. Windows 7 64bit. Bellow is the message I get that makes me think it worked but it doesn't. Any help would be great.


Using backup folder C:\gmailbackups\scott
Using folder [Gmail]/All Mail
GYB needs to examine 702 messages
GYB already has a backup of 0 messages
GYB needs to backup 702 messages
backed up 702 of 702 messages

GYB needs to refresh 0 messages

C:\gyb-64>

After running it the 2nd time I get this:


Using backup folder C:\gmailbackups\scott
Using folder [Gmail]/All Mail
GYB needs to examine 702 messages
GYB already has a backup of 702 messages
GYB needs to backup 0 messages

GYB needs to refresh 702 messages

refreshed 702 of 702 messages

But the folder is still empty,

Error restoring with UnicodeEncodeError

Hi,

I am restoring my old gmail email to a new gmail acocunt. I have come across an error:

UnicodeEncodeError: 'latin-1' codec can't encode character '\udce1'

error-image

How can I overcome this? Is there a command I can use to ignore these characters and skip the error?
Many Thanks for any help.

Group -> Mailbox

I see you can go from a mailbox to a group using gyb but I need to go the other way - I have a collaborative mailbox group that I need to migrate to a standard google apps account and mailbox. As far as I can see this isn't possible with gyb but thought I'd check.

Feature request: inverse order for populating Groups

Hi, I've been using GYB many times, mainly for small backup/restore operations on Google Apps accounts and groups.
I've noticed that when restoring e-mail to groups, the order of the messages is determined by the upload time and not by the message date header.
Is possible to add a switch in restore-group option to make GYB use inverse order (from older to newer messages), so the message order in group remain correct (newer messages on top, older on bottom)?

Many thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.