This commit is contained in:
Alban Bronisz 2021-12-06 16:46:42 +01:00
parent a65144d894
commit eccd0635e5
1 changed files with 9 additions and 8 deletions

View File

@ -1,15 +1,15 @@
#!/bin/bash
#!/bin/env bash
set -e # Exit if error
# This script synchronises data from FTP into local folder:
# 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 modificaiton will be done in the FTP, as the mount is done in read only mode.
# 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.
set -e # Exit if error
# =============================================================================
# Configuration
@ -19,7 +19,7 @@ FTP_PASS=ftp
FTP_IP=192.168.1.21
FTP_PORT=2121
SOURCE=phone-ftp/ # Temporary local folder, to mount FTP folder
SOURCE=tmp_phone-ftp/ # Temporary local folder, to mount FTP folder
DESTINATION=phone/ # Local folder where to save files
@ -34,9 +34,10 @@ EXCLUDE_DIR=save
echo "========================================================================"
echo SOURCE: ${SOURCE}
echo DESTINATION: ${DESTINATION}
echo "========================================================================"
mkdir -p ${DESTINATION}
@ -53,8 +54,8 @@ for ((i=0; i<${#LINK[@]}; i+=2)); do
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}/"
# 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