Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
executable file 43 lines (37 sloc) 1.96 KB
# adapted from https://github.com/PeterKaminski09/baskup/blob/master/baskup.sh
BACKUP_DIR=./backup
OS_Version=$(sw_vers -productVersion)
LAST_VERSION=10.13
NEEDS_MODIFICATION=$(echo $OS_Version '>=' $LAST_VERSION)
BACKUP_ATTACHMENTS=1
for line in $(sqlite3 /Users/[me]/gpt-2/scripts/baskup-master/imessagedb "select distinct guid from chat;" ); do
echo "."
contact=$line
arrIN=(${contact//;/ })
contactNumber=${arrIN[2]}
#Make a directory specifically for this folder
mkdir -p $BACKUP_DIR/$contactNumber/Attachments
#Perform SQL operations
if [[ $NEEDS_MODIFICATION == 1 ]]; then
sqlite3 /Users/[me]/gpt-2/scripts/baskup-master/imessagedb "
select is_from_me,text, datetime((date/1000000000) + strftime('%s', '2001-01-01 00:00:00'), 'unixepoch', 'localtime') as date from message where handle_id=(
select handle_id from chat_handle_join where chat_id=(
select ROWID from chat where guid='$line')
)" | sed 's/1\|/Me: /g;s/0\|/Friend: /g' > $BACKUP_DIR/$contactNumber/$line.txt
else
sqlite3 /Users/[me]/gpt-2/scripts/baskup-master/imessagedb "
select is_from_me,text, datetime(date + strftime('%s', '2001-01-01 00:00:00'), 'unixepoch', 'localtime') as date from message where handle_id=(
select handle_id from chat_handle_join where chat_id=(
select ROWID from chat where guid='$line')
)" | sed 's/1\|/Me: /g;s/0\|/Friend: /g' > $BACKUP_DIR/$contactNumber/$line.txt
fi
if [[ $BACKUP_ATTACHMENTS == 1 ]]; then
sqlite3 /Users/[me]/gpt-2/scripts/baskup-master/imessagedb "
select filename from attachment where rowid in (
select attachment_id from message_attachment_join where message_id in (
select rowid from message where cache_has_attachments=1 and handle_id=(
select handle_id from chat_handle_join where chat_id=(
select ROWID from chat where guid='$line')
)))" | cut -c 2- | awk -v home=$HOME '{print home $0}' | tr '\n' '\0' | xargs -0 -I fname cp fname $BACKUP_DIR/$contactNumber/Attachments
fi
done
You can’t perform that action at this time.