Skip to content

Instantly share code, notes, and snippets.

@gliborgmx
Last active August 29, 2015 14:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gliborgmx/053b50608255de032d3a to your computer and use it in GitHub Desktop.
Save gliborgmx/053b50608255de032d3a to your computer and use it in GitHub Desktop.
script for mirror geeklog site using lftp
#!/bin/bash
LFTP=`which lftp` || exit "Can't find lftp"
SITE=ftp://user@example.com
show_help()
{
echo "This script will mirror, using lftp, the site."
echo ""
echo "-h\t\tthis message"
echo "-v\t\tverbose output"
echo "-d\t\tdelete files not present at remote site"
echo "-r\t\treverse mirror (put files)"
}
run()
{
command="set ftp:ssl-allow no ; $1 ; quit"
${LFTP} ${SITE} -e "${command}"
}
OPTIND=1
delete=""
verbose=""
reverse=""
dryrun=""
directory="geeklog-2.1.0/" # local and remote directory name
while getopts "h?vdrs" opt; do
case "$opt" in
h|\?)
show_help
exit 0
;;
v) verbose="-vvv"
;;
d) delete="--delete"
;;
r) reverse="--reverse"
;;
s) dryrun="--dry-run"
;;
esac
done
shift $((OPTIND-1))
[ "$1" = "--" ] && shift
if [ ! -d $directory ]; then
exit "Can't find local directory to mirror"
fi
params="--parallel=5 --no-symlinks --exclude=layout_cache ${verbose} ${delete} ${reverse} ${dryrun}"
run "mirror ${params} --exclude=public_html ${directory} ${directory}"
cd ${directory}
run "mirror ${params} --exclude=backend public_html public_html"
cd -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment