Skip to content

Instantly share code, notes, and snippets.

@marsam
Last active April 3, 2018 17:00
Show Gist options
  • Save marsam/9279301 to your computer and use it in GitHub Desktop.
Save marsam/9279301 to your computer and use it in GitHub Desktop.
ftp mirror
#!/usr/bin/env bash
set -e
host="ftp.example.com"
user="user"
pass="pasword"
ftpurl="ftp://${user}:${pass}@${host}"
local_dir="/path/to/local/dir"
remote_dir="documents" # Only mirror this remote dir
[[ -d $local_dir ]] || mkdir -p $local_dir
lftp -c "set ftp:list-options -a;
open '$ftpurl';
lcd $local_dir;
cd $remote_dir;
mirror --verbose \
--continue \
"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment