#!/bin/bash HOST="123.123.123:21" # FTP服务器地址 USER="username" # FTP用户名 PASS="password" # FTP密码 SCD="/" # 远程根目录 LCD="/home/www/" # 本地根目录 LST="dir1 dir2 dir3" # 要同步的目录, 空格隔开 for RCD in $LST; do mkdir -p $LCD$RCD lftp -c "open ftp://$USER:$PASS@$HOST; lcd $LCD$RCD; cd $SCD$RCD; mirror --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" done