From a17c56f2435e1be14432b12e05b94cf8d97eac76 Mon Sep 17 00:00:00 2001
From: Bob Mottram <bob.mottram@codethink.co.uk>
Date: Thu, 7 Jul 2016 11:56:21 +0100
Subject: [PATCH] Local backup for ipfs

---
 src/freedombone-app-ipfs | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/src/freedombone-app-ipfs b/src/freedombone-app-ipfs
index 368a9f83e..c95c52be2 100755
--- a/src/freedombone-app-ipfs
+++ b/src/freedombone-app-ipfs
@@ -47,11 +47,24 @@ function upgrade_ipfs {
 }
 
 function backup_local_ipfs {
-    echo ''
+	if ! grep -q "Admin user" $COMPLETION_FILE; then
+		return
+	fi
+	ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}')
+	source_directory=/home/$ADMIN_USERNAME/.ipfs
+	if [ -d $source_directory ]; then
+		dest_directory=ipfs
+		echo $"Backing up $source_directory to $dest_directory"
+
+		function_check backup_directory_to_usb
+		backup_directory_to_usb $source_directory $dest_directory
+
+		echo $"Backup to $dest_directory complete"
+	fi
 }
 
 function backup_remote_ipfs {
-    echo ''
+	echo -n ''
 }
 
 function remove_ipfs {
-- 
GitLab