forked from fizzy33/a8-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgmail_backup.py
More file actions
58 lines (31 loc) · 1.49 KB
/
gmail_backup.py
File metadata and controls
58 lines (31 loc) · 1.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/usr/bin/env python
import os
from subprocess import call
import shutil
account = "foo@bar.com"
print(""""
So you want to backup an email account. You should have already hopped into
gmail admin made sure the account is active and reset the password to something known.
Also you would have done something like
pip install --user gmvault
gmvault does some funky browser stuff to get an oauth token and this behavious is different on each platform.
Worst case just quit whatever browser it sticks you in and get back to the terminal and it will give you an oauth url cut
paste that into an incognito browser window and login as that user and get the oauth token that is provided at the end. Cut
and paste that into the session.
Note it is important to use an incognito session so that you are logging into that users account and not your own.
""")
raw_input("we will delete any pre-existing gmvault databases or settings on this machine press ENTER to continue")
def delete_tree(path):
epath = os.path.expanduser(path)
if os.path.exists(epath):
print("removing " + epath)
shutil.rmtree(epath)
delete_tree("~/.gmvault")
delete_tree("~/gmvault-db")
print("running gmvault sync")
call(["gmvault", "sync", account])
print("""
!!! SUCCESS !!!
okay looks like that worked... Now do something like this to rsync the backed up user to nettle.accur8.io
rsync --compress --archive --partial --progress --stats ~/gmvault-db user@server@bar:/ebs/former-employees-emails/foo@bar
""")