-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackup.py
More file actions
31 lines (24 loc) · 1.05 KB
/
backup.py
File metadata and controls
31 lines (24 loc) · 1.05 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
#!/usr/bin/python
from shutil import copyfile
import sqlite3
import sys
import hashlib
import os
backup = sys.argv[1]
basepath = os.path.expanduser('~')+"/Library/Application Support/MobileSync/Backup/%s/" % backup
conn = sqlite3.connect(basepath+"3d/3d0d7e5fb2ce288813306e4d4636395e047a3d28")
c = conn.cursor()
c.execute("SELECT filename, transfer_name FROM chat LEFT OUTER JOIN chat_message_join ON chat.ROWID = chat_id LEFT OUTER JOIN message ON message.ROWID = chat_message_join.message_id LEFT OUTER JOIN message_attachment_join ON message.ROWID = message_attachment_join.message_id LEFT OUTER JOIN attachment ON attachment_id = attachment.ROWID")
if not os.path.exists(os.path.expanduser('~')+"/Desktop/_export"):
os.makedirs(os.path.expanduser('~')+"/Desktop/_export")
for row in c.fetchall():
if not row[0]:
continue
filepath = row[0].replace('~/', 'MediaDomain-')
sha = hashlib.sha1()
sha.update(filepath)
filename = sha.hexdigest()
try:
copyfile(basepath+filename[:2]+"/"+filename, os.path.expanduser('~')+"/Desktop/_export/"+row[1])
except:
pass