1、备份远程服务器x.x.x.50的FTPserver上的某个文件夹,比如databakup,其中有几个文件夹不需要同步,需要排除
2、推送本地一个文件夹到远程x.x.x.50的FTPserver的上面
实现方法,查了一些资料,感觉使用lftp的脚本功能配合crontab来实现比较靠谱
有几个疑问:
1、相同大小的文件是否跳过
2、脚本的一些参数不太明白是什么意思
脚本范本如下:
代码: 全选
通过lftp的mirror模式(ncftp也有mirror模式)
从FTP服务器上备份到本地
A、命令行方式
lftp -c "set ftp:list-options -a;
open ftp://user:password@your.ftp.com;
lcd ./web;
cd /web/public_html;
mirror --delete --use-cache --verbose --allow-chown
--allow-suid --no-umask --parallel=2 --exclude-glob .svn"
B、脚本方式
#!/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 --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"
从本地恢复到FTP服务器上
A、命令行方式
lftp -c "set ftp:list-options -a;
open ftp://user:password@your.ftp.com;
lcd ./web;
cd /web/public_html;
mirror --reverse --delete --use-cache --verbose --allow-chown
--allow-suid --no-umask --parallel=2 --exclude-glob .svn"
B、脚本方式
#!/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"
两种方式间主要的差别就是在–reverse选项上,有这个选项就是put files,反之则是get files。