Skip to content

Instantly share code, notes, and snippets.

@sathishshan
Created May 6, 2019 01:29
Show Gist options
  • Save sathishshan/b7137b0e8113848ed514da4754230c19 to your computer and use it in GitHub Desktop.
Save sathishshan/b7137b0e8113848ed514da4754230c19 to your computer and use it in GitHub Desktop.
# General mirror
USER=""
PASSWORD=""
HOST=""
REMOTE_DIR=""
LOCAL_DIR=""
lftp -u "$USER","$PASSWORD" $HOST <<EOF
# the next 3 lines put you in ftpes mode. Uncomment if you are having trouble connecting.
# set ftp:ssl-force true
# set ftp:ssl-protect-data true
# set ssl:verify-certificate no
# transfer starts now...
mirror -P10 --size-range=0-9M $REMOTE_DIR $LOCAL_DIR && bye;
exit
EOF
# include-glob:
lftp -u $USER,$PASSWORD -e 'mirror -P10 --continue --size-range=0-9M $REMOTE_DIR --include-glob "*.js" $LOCAL_DIR && bye' $HOST
# exclude:
lftp -u $USER,$PASSWORD -e 'mirror -P10 --continue --size-range=0-9M $REMOTE_DIR --exclude path/or/file $LOCAL_DIR && bye' $HOST
# Some files alone by giving the paths:
Whil read path; do
lftp -u $USER,$PASSWORD -e 'mirror -P10 --continue --size-range=0-9M $path $LOCAL_DIR && bye' $HOST
done < filepaths_to_mirror.txt
# file_permission issue:
lftp <<EOF
# the next 3 lines put you in ftpes mode. Uncomment if you are having trouble connecting.
#set ftp:ssl-allow no
#set ftp:passive-mode true
#set ftp:list-options -a
open -u [user],[password] [host]
# changing file permissions starts now...
chmod 777 /public_html/images/cache/thanos.jpeg
EOF
# miscellaneous:
lftp_rc
should do it.
If this doesn't work try adding to your /etc/lftp.conf the following lines:
set ftp:ssl-protect-data true
set ftp:ssl-force true
set ftp:ssl-auth TLS
set ssl:verify-certificate no
# cache flush
# ls | tr "\n" " "
@sathishshan
Copy link
Author

It may be useful!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment