Skip to content

Instantly share code, notes, and snippets.

@gliborgmx gliborgmx/site-sync.sh
Last active Aug 29, 2015

Embed
What would you like to do?
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
You can’t perform that action at this time.