From 44f650d1ed95a7af24ef619b6d44c74ee81fbc8d Mon Sep 17 00:00:00 2001 From: Alban Bronisz Date: Sun, 21 Nov 2021 13:01:44 +0100 Subject: [PATCH] First version --- README.md | 37 ++++++++++++++++++++++++++++ synch_phone.sh | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) create mode 100644 README.md create mode 100755 synch_phone.sh diff --git a/README.md b/README.md new file mode 100644 index 0000000..5abb25b --- /dev/null +++ b/README.md @@ -0,0 +1,37 @@ + +Save your Android data using internal wifi network +================================================== + +Install +------- + +### On your box configuration page + +Go on your box web configuration page. + +For SFR box go on https://192.168.1.1/ +Sometimes, authentication can be done directly with a 5s press on a box button. + +Then freeze the Android local IP address, in the DHCP configuration (something like 192.168.1.XX). + + + +### On mobile phone +Add an FTP server. + +One can use [FTP Server (Free)](https://f-droid.org/en/packages/be.ppareit.swiftp_free/). + + +### On the computer +Configure the script [synch_phone.sh](./synch_phone.sh) (doc is embedded on the first lines). + + +Synchronize +----------- + +At home, connect your mobile and computer to the wifi. +Start the mobile FPT server. +Launch the script : + + ./synch_phone.sh + diff --git a/synch_phone.sh b/synch_phone.sh new file mode 100755 index 0000000..1715390 --- /dev/null +++ b/synch_phone.sh @@ -0,0 +1,66 @@ +#!/bin/bash + + +# This script synchronises data from FTP into local folder: +# - remove file that do not exist anymore in the FTP (rsync --delete flag) +# - do not update file (a file that already existing locally will be ignore, rsync --ignore-existing flag)) +# +# No modificaiton will be done in the FTP, as the mount is done in read only mode. +# +# Configuration is gathered at the beginning of the script. + +set -e # Exit if error + +# ============================================================================= +# Configuration +# ============================================================================= +FTP_USER=ftp +FTP_PASS=ftp +FTP_IP=192.168.1.21 +FTP_PORT=2121 + +SOURCE=phone-ftp/ # Temporary local folder, to mount FTP folder +DESTINATION=phone/ # Local folder where to save files + + +LINK=() +LINK+=("WhatsApp/Media/WhatsApp Video" "WhatsApp/WhatsApp Video") +LINK+=("WhatsApp/Media/WhatsApp Images" "WhatsApp/WhatsApp Images") +LINK+=("DCIM/Camera" "DCIM") + +EXCLUDE_DIR=save + +# ============================================================================= + + + + +echo SOURCE: ${SOURCE} +echo DESTINATION: ${DESTINATION} +mkdir -p ${DESTINATION} + + +echo "Mount FTP folder in ${SOURCE} in read-only" +if [ ! -d ${SOURCE} ]; then + mkdir -p ${SOURCE} + curlftpfs -r ${FTP_USER}:${FTP_PASS}@${FTP_IP}:${FTP_PORT}/ ${SOURCE} +fi + +echo curlftpfs -r ${FTP_USER}:${FTP_PASS}@${FTP_IP}:${FTP_PORT}/ ${SOURCE} +echo "Start synchronisation" +for ((i=0; i<${#LINK[@]}; i+=2)); do + SOURCE_DIR=${LINK[i]} + DESTINATION_DIR=${LINK[i+1]} + echo "############################## ${SOURCE_DIR} > ${DESTINATION_DIR}" + mkdir -p "${DESTINATION}/${DESTINATION_DIR}/" + # WARNING with source, rsyn do: copy folder with src but only folder content with src/ + rsync -rv --delete --ignore-existing --exclude "EXCLUDE_DIR" "${SOURCE}/${SOURCE_DIR}/" "${DESTINATION}/${DESTINATION_DIR}/" +done + + +# Wait that rsync free FTP mounted folder +sleep 1 + +echo "Remove mounted ${SOURCE}" +fusermount -u ${SOURCE} +rmdir ${SOURCE}