New version, lighter, using lftp
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
Phone
|
||||
Card
|
||||
@@ -5,11 +5,14 @@ Save your Android data using internal wifi network
|
||||
Install
|
||||
-------
|
||||
|
||||
### On your box configuration page
|
||||
### Freeze your local phone IP on your internet box
|
||||
**Note:** This step is not mandatory. You can skip it but then your IP will change at each connection.
|
||||
Those, you will have to update script each time with the proper IP.
|
||||
|
||||
|
||||
Go on your box web configuration page.
|
||||
|
||||
For SFR box go on https://192.168.1.1/
|
||||
For SFR box go on [https://192.168.1.1/](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).
|
||||
@@ -20,22 +23,30 @@ Then freeze the Android local IP address, in the DHCP configuration (something l
|
||||
Add an FTP server.
|
||||
|
||||
One can use [FTP Server (Free)](https://f-droid.org/en/packages/be.ppareit.swiftp_free/).
|
||||
This app has a widget that show IP address when turned on.
|
||||
|
||||
|
||||
### On the computer
|
||||
- Install `curlftpfs`
|
||||
- Install `lftp`
|
||||
|
||||
sudo apt install curlftpfs
|
||||
sudo apt install lftp
|
||||
|
||||
- Configure the script [synch_phone.sh](./synch_phone.sh) (doc is embedded on the first lines).
|
||||
- Configure the script [phone_synch.sh](./phone_synch.sh) (doc is embedded on the first lines).
|
||||
|
||||
|
||||
Synchronize
|
||||
-----------
|
||||
|
||||
At home, connect your mobile and computer to the wifi.
|
||||
Start the mobile FPT server.
|
||||
Start the mobile FPT server, using the widget
|
||||
Launch the script :
|
||||
|
||||
./synch_phone.sh
|
||||
|
||||
|
||||
Have also a memory card on your phone?
|
||||
--------------------------------------
|
||||
No problemo :)
|
||||
Configure also the script [card_synch.sh](./card_synch.sh) and to launch both synchronisation, run:
|
||||
|
||||
./run.sh
|
||||
|
||||
|
||||
Executable
+49
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
set -e # Exit if error
|
||||
|
||||
|
||||
# This script synchronizes data from FTP into local folder:
|
||||
# - remove file that do not exist anymore in the FTP (mirror -e)
|
||||
#
|
||||
# No modification will be done in the FTP.
|
||||
#
|
||||
# Configuration is gathered at the beginning of the script.
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Configuration
|
||||
# =============================================================================
|
||||
FTP_USER=card
|
||||
FTP_PASS=card
|
||||
FTP_IP=192.168.1.21
|
||||
FTP_PORT=2121
|
||||
|
||||
|
||||
DESTINATION=Card/ # Local folder where to save files
|
||||
|
||||
# List of folders to save
|
||||
# example: LINK+=("/distant/dir" "dir2")
|
||||
# will saved FTP folder "/distant/dir" in local folder "$DESTINATION/dir2"
|
||||
|
||||
LINK=()
|
||||
LINK+=("Download" "Download")
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# =============================================================================
|
||||
echo "Start synchronisation"
|
||||
for ((i=0; i<${#LINK[@]}; i+=2)); do
|
||||
DISTANT_DIR=${LINK[i]}
|
||||
LOCAL_DIR=${LINK[i+1]}
|
||||
echo "############################## ${DISTANT_DIR} > ${LOCAL_DIR}"
|
||||
mkdir -p "${DESTINATION}/${LOCAL_DIR}/"
|
||||
|
||||
lftp ftp://${FTP_USER}:${FTP_PASS}@${FTP_IP}:${FTP_PORT} -e "mirror -e -x .thumbnails -x "saved" \"${DISTANT_DIR}\" \"${DESTINATION}/${LOCAL_DIR}\" ; quit"
|
||||
done
|
||||
|
||||
|
||||
|
||||
Executable
+49
@@ -0,0 +1,49 @@
|
||||
#!/bin/bash
|
||||
set -e # Exit if error
|
||||
|
||||
|
||||
# This script synchronizes data from FTP into local folder:
|
||||
# - remove file that do not exist anymore in the FTP (mirror -e)
|
||||
#
|
||||
# No modification will be done in the FTP.
|
||||
#
|
||||
# Configuration is gathered at the beginning of the script.
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Configuration
|
||||
# =============================================================================
|
||||
FTP_USER=ftp
|
||||
FTP_PASS=ftp
|
||||
FTP_IP=192.168.1.21
|
||||
FTP_PORT=2121
|
||||
|
||||
|
||||
DESTINATION=Phone/ # Local folder where to save files
|
||||
|
||||
# List of folders to save
|
||||
# example: LINK+=("/distant/dir" "dir2")
|
||||
# will saved FTP folder "/distant/dir" in local folder "$DESTINATION/dir2"
|
||||
|
||||
LINK=()
|
||||
LINK+=("/WhatsApp/Media/WhatsApp Video" "WhatsApp_Video")
|
||||
LINK+=("/WhatsApp/Media/WhatsApp Images" "WhatsApp_Images")
|
||||
LINK+=("/DCIM" "DCIM")
|
||||
LINK+=("/Download" "Download")
|
||||
LINK+=("/Documents" "Documents")
|
||||
LINK+=("/Pictures" "Pictures")
|
||||
|
||||
|
||||
# =============================================================================
|
||||
echo "Start synchronisation"
|
||||
for ((i=0; i<${#LINK[@]}; i+=2)); do
|
||||
DISTANT_DIR=${LINK[i]}
|
||||
LOCAL_DIR=${LINK[i+1]}
|
||||
echo "############################## ${DISTANT_DIR} > ${LOCAL_DIR}"
|
||||
mkdir -p "${DESTINATION}/${LOCAL_DIR}/"
|
||||
|
||||
lftp ftp://${FTP_USER}:${FTP_PASS}@${FTP_IP}:${FTP_PORT} -e "mirror -e -x .thumbnails -x "saved" \"${DISTANT_DIR}\" \"${DESTINATION}/${LOCAL_DIR}\" ; quit"
|
||||
done
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e # Exit if error
|
||||
|
||||
./phone_sync.sh
|
||||
./card_sync.sh
|
||||
@@ -1,69 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e # Exit if error
|
||||
|
||||
|
||||
# This script synchronizes 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 modification will be done in the FTP, as the mount is done in read only mode.
|
||||
#
|
||||
# Configuration is gathered at the beginning of the script.
|
||||
|
||||
|
||||
# =============================================================================
|
||||
# Configuration
|
||||
# =============================================================================
|
||||
FTP_USER=ftp
|
||||
FTP_PASS=ftp
|
||||
FTP_IP=192.168.1.21
|
||||
FTP_PORT=2121
|
||||
|
||||
SOURCE=tmp_phone-ftp/ # Temporary local folder, to mount FTP folder
|
||||
DESTINATION=phone/ # Local folder where to save files
|
||||
|
||||
|
||||
LINK=()
|
||||
LINK+=("WhatsApp/Media" "WhatsApp")
|
||||
LINK+=("DCIM" "DCIM")
|
||||
|
||||
EXCLUDE_DIR=saved
|
||||
|
||||
# =============================================================================
|
||||
|
||||
|
||||
|
||||
echo "========================================================================"
|
||||
echo SOURCE: ${SOURCE}
|
||||
echo DESTINATION: ${DESTINATION}
|
||||
echo "========================================================================"
|
||||
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}
|
||||
echo curlftpfs -r ${FTP_USER}:${FTP_PASS}@${FTP_IP}:${FTP_PORT}/ ${SOURCE}
|
||||
fi
|
||||
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}"
|
||||
if [ ! -d "${SOURCE}/${SOURCE_DIR}" ]; then
|
||||
echo "WARNING - cannot find ${SOURCE}/${SOURCE_DIR}"
|
||||
continue
|
||||
fi
|
||||
mkdir -p "${DESTINATION}/${DESTINATION_DIR}/"
|
||||
# WARNING with source, rsync 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}
|
||||
Reference in New Issue
Block a user