Skip to content

Instantly share code, notes, and snippets.

@ChrisBuchholz
Created June 15, 2012 21:27
Show Gist options
  • Select an option

  • Save ChrisBuchholz/2938782 to your computer and use it in GitHub Desktop.

Select an option

Save ChrisBuchholz/2938782 to your computer and use it in GitHub Desktop.
script to set up dir mirroring with lftp
## http://serverfault.com/a/106365
##
## As written by esel
##
## lftp is very good tool.
##
## I suggest you to parametrize the script, and make use of the
##
## exclude-glob
## options, that excludes filenames using the glob feature (*,? ..) of your shell:
#!/bin/bash
HOST="your.ftp.host.dom"
USER="username"
PASS="password"
LCD="/path/of/your/local/dir"
RCD="/path/of/your/remote/dir"
lftp -c "set ftp:list-options -a;
open ftp://$USER:$PASS@$HOST;
lcd $LCD;
cd $RCD;
mirror --reverse \
--delete \
--verbose \
--exclude-glob a-dir-to-exclude/ \
--exclude-glob a-file-to-exclude \
--exclude-glob a-file-group-to-exclude* \
--exclude-glob other-files-to-esclude"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment