Last active
May 25, 2019 19:02
-
-
Save jobliz/e0675b7e422683ea052a3e34794c0145 to your computer and use it in GitHub Desktop.
A script to sync a local directory with a remote directory through FTP.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# A script to sync a local directory with a remote directory through FTP. The local directory contents | |
# will overwrite the remote directory. If a file was deleted locally, it will be deleted remotely. | |
# Notes: | |
# | |
# - It excludes the content of the .git directory. | |
# - The -P flag is for parallelizing work. | |
# - 'set ssl:verify-certificate false' might not be necessary. YMMV. | |
# | |
# See: | |
# https://askubuntu.com/questions/758640/how-to-automatically-sync-the-contents-of-a-local-folder-with-the-contents-of-a | |
# https://serverfault.com/questions/291255/what-is-the-syntax-of-lftps-mirror-x-exclude-option | |
# https://techoverflow.net/2018/08/07/how-to-disable-ssl-certification-verification-in-lftp/ | |
HOST='example.com' | |
USER='[email protected]' | |
PASS='123456' | |
TARGETFOLDER='/' | |
SOURCEFOLDER='/home/you/directory' | |
lftp -f " | |
set ssl:verify-certificate false | |
open $HOST | |
user $USER $PASS | |
lcd $SOURCEFOLDER | |
mirror --reverse --only-newer --ignore-time --delete --verbose -P 4 -x ^\.git/$ $SOURCEFOLDER $TARGETFOLDER | |
bye | |
" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment