From cf9aa8b50e50bbffe293422195f52b494b4fe8f0 Mon Sep 17 00:00:00 2001
From: Nico Alt <nicoalt@posteo.org>
Date: Tue, 15 Oct 2019 15:43:21 +0200
Subject: [PATCH] Add script to copy database from Android devices

---
 README.md                     |  3 +++
 tools/copy-db-from-android.sh | 21 +++++++++++++++++++++
 2 files changed, 24 insertions(+)
 create mode 100755 tools/copy-db-from-android.sh

diff --git a/README.md b/README.md
index dd864d7..feac42a 100644
--- a/README.md
+++ b/README.md
@@ -49,6 +49,9 @@ convenient way to do so is by using
 [_adb_](https://developer.android.com/studio/command-line/adb).
 Note that your smartphone needs to be rooted for this.
 
+You can either use the script at 
+[tools/copy-db-from-android.sh](tools/copy-db-from-android.sh) or do it manually:
+
 1. Start _briar-gtk_ and register a dummy account. This will create
 the needed directory structure at _~/.briar/_. Close the program afterwards.
 2. Enable _adb_ on your smartphone and give it root permissions.
diff --git a/tools/copy-db-from-android.sh b/tools/copy-db-from-android.sh
new file mode 100755
index 0000000..1056cfe
--- /dev/null
+++ b/tools/copy-db-from-android.sh
@@ -0,0 +1,21 @@
+#!/usr/bin/env bash
+# Copyright (c) 2019 Nico Alt
+# SPDX-License-Identifier: AGPL-3.0-only
+# License-Filename: LICENSE.md
+
+# Script to copy Briar database from Android to Linux devices.
+# Note that you must have started Briar GTK beforehand.
+# It's also recommend to manually start adb before using this script.
+
+set -e -x
+
+# List devices
+adb devices
+
+# Switch to root mode
+adb root
+
+# Copy files
+adb pull /data/data/org.briarproject.briar.android/app_db/db.mv.db ~/.briar/db/
+adb pull /data/data/org.briarproject.briar.android/app_key/db.key ~/.briar/key/
+adb pull /data/data/org.briarproject.briar.android/app_key/db.key.bak ~/.briar/key/
-- 
GitLab