diff --git a/card_sync.sh b/card_sync.sh index 5a910d1..6a7a064 100755 --- a/card_sync.sh +++ b/card_sync.sh @@ -15,7 +15,7 @@ set -e # Exit if error # ============================================================================= FTP_USER=card FTP_PASS=card -FTP_IP=192.168.1.21 +FTP_IP=192.168.1.30 FTP_PORT=2121 @@ -26,6 +26,7 @@ DESTINATION=Card/ # Local folder where to save files # will saved FTP folder "/distant/dir" in local folder "$DESTINATION/dir2" LINK=() +LINK+=("DCIM" "DCIM") LINK+=("Download" "Download") @@ -35,14 +36,23 @@ LINK+=("Download" "Download") # ============================================================================= -echo "Start synchronisation" +echo "=========================================================" +echo "Start synchronisation to ${DESTINATION}" +echo "=========================================================" +find ${DESTINATION} -type f -exec chmod 644 {} \; +find ${DESTINATION} -type d -exec chmod 755 {} \; + 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" + if lftp ftp://${FTP_USER}:${FTP_PASS}@${FTP_IP}:${FTP_PORT} -e "mirror -e -x .thumbnails -x "saved" \"${DISTANT_DIR}\" \"${DESTINATION}/${LOCAL_DIR}\" ; quit" ; then + echo "Success :)" + else + echo 'Failed !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' + fi done diff --git a/phone_sync.sh b/phone_sync.sh index 329f683..5738e35 100755 --- a/phone_sync.sh +++ b/phone_sync.sh @@ -15,7 +15,7 @@ set -e # Exit if error # ============================================================================= FTP_USER=ftp FTP_PASS=ftp -FTP_IP=192.168.1.21 +FTP_IP=192.168.1.30 FTP_PORT=2121 @@ -26,24 +26,34 @@ DESTINATION=Phone/ # Local folder where to save files # will saved FTP folder "/distant/dir" in local folder "$DESTINATION/dir2" LINK=() +LINK+=("/DCIM" "DCIM") +LINK+=("/Pictures" "Pictures") +LINK+=("/Download" "Download") 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" +echo "=========================================================" +echo "Start synchronisation to ${DESTINATION}" +echo "=========================================================" +find ${DESTINATION} -type f -exec chmod 644 {} \; +find ${DESTINATION} -type d -exec chmod 755 {} \; + 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" + if lftp ftp://${FTP_USER}:${FTP_PASS}@${FTP_IP}:${FTP_PORT} -e "mirror -e -x .thumbnails -x "saved" \"${DISTANT_DIR}\" \"${DESTINATION}/${LOCAL_DIR}\" ; quit" ; then + echo "Success :)" + else + echo 'Failed !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!' + fi done + diff --git a/run.sh b/run.sh index 4a6d886..13b0129 100755 --- a/run.sh +++ b/run.sh @@ -2,5 +2,6 @@ set -e # Exit if error + ./phone_sync.sh ./card_sync.sh