我目前的情况下,我有一台服务器的渠道非常有限递归PUT文件到远程服务器,但需要上传和下载包含在一个单一的目录结构中的文件的显著量。我没有SSH访问权限,所以我不能使用SCP - 不幸的是,rsync不是一种选择。使用FTP
我目前使用ncftpput,这是伟大的,但似乎是相当缓慢的(尽管快速连接的)。
是否有其他/更好的方法,我可以看看?
(请接受我的道歉,如果这已经覆盖了,我做了一个快速搜索发布之前,但没有发现任何明确回答我的问题)
我目前的情况下,我有一台服务器的渠道非常有限递归PUT文件到远程服务器,但需要上传和下载包含在一个单一的目录结构中的文件的显著量。我没有SSH访问权限,所以我不能使用SCP - 不幸的是,rsync不是一种选择。使用FTP
我目前使用ncftpput,这是伟大的,但似乎是相当缓慢的(尽管快速连接的)。
是否有其他/更好的方法,我可以看看?
(请接受我的道歉,如果这已经覆盖了,我做了一个快速搜索发布之前,但没有发现任何明确回答我的问题)
我不熟悉ncftpput
。对于非交互式FTP,我一直使用Perl Net :: FTP模块 - http://perldoc.perl.org/Net/FTP.html
这样会更快,因为您可以登录,然后立即执行所有传输(从粗略浏览看来,您似乎执行ncftpput
每个文件get/put一次)。
只要记得不要使用ASCII忙玲!这是默认的,所以使用:
$ftp->binary
ASCII mangling需要死在与MySQL自动时区解释相同的火灾。
如果你有一个很好的连接,我会建议安装通过GNOME或KDE文件管理器,或者使用CurlFtpFS FTP服务器。然后你可以把它当作另一个文件夹。
This是一个可怕的答案。这样做不会比FTP更快,而且风险更大,特别是对于大量数据,因为它不支持中断恢复。如果他无法访问SSH,他将如何配置它进行安装? – Benubird 2013-03-15 11:49:49
不需要服务器配置。服务器已经配置为FTP。关键不是让事情变得更快,而是让它们变得更容易。使用CurlFtpFS安装后,可以使用标准的unix utils,如cp和rsync。我确实说过,它有很好的连接效果。 – 2013-03-15 15:27:03
因为我总是最后有这个问题,我会在这里发布我的笔记:
有一件事我一直弄混淆的是语法;所以下面有它创建一些临时目录一个bash
测试脚本,然后启动一个临时的FTP服务器,并比较rsync
(以纯本地文件模式,因为它不支持FTP)与lftp
和ftpsync
。
事情是 - 你可以使用rsync /path/to/local /path/to/remote/
,rsync会自动计算出来,你想要一个local
子目录下创建的remote
;然而,对于lftp
或ftpsync
你有手动指定目标目录,如... /path/to/local /path/to/remote/local
(如果它不存在将创建它)。
您可以在How do I temporarily run an FTP server? - Ask Ubuntu中找到ftpserver-cli.py
;和ftpsync
在这里:FTPsync(但是,请注意它是越野车;也可参见Search/grep ftp remote filenames - Unix & Linux Stack Exchange);
这里是puttest.sh
脚本的缩短的输出,显示在不同的情况下,递归放行为:
$ bash puttest.sh
Recreate directories; populate loctest, keep srvtest empty:
show dirs:
+ tree --noreport -a /tmp/srvtest /tmp/loctest
/tmp/srvtest
/tmp/loctest
├── .git
│ └── tempa2.txt
└── tempa1.txt
*NOTE, rsync can automatically figure out parent dir:
+ rsync -a --exclude '*.git*' /tmp/loctest /tmp/srvtest/
show dirs:
+ tree --noreport -a /tmp/srvtest /tmp/loctest
/tmp/srvtest
└── loctest
└── tempa1.txt
/tmp/loctest
├── .git
│ └── tempa2.txt
└── tempa1.txt
cleanup:
+ rm -rf /tmp/srvtest/loctest
Start a temporary ftp server:
+ sudo bash -c 'python /path/to/pyftpdlib/ftpserver-cli.py --username=user --password=12345 --directory=/tmp/srvtest &'
+ sleep 1
Using: user: user pass: 12345 port: 21 dir: /tmp/srvtest
[I 14-03-02 23:24:01] >>> starting FTP server on 127.0.0.1:21, pid=21549 <<<
[I 14-03-02 23:24:01] poller: <class 'pyftpdlib.ioloop.Epoll'>
[I 14-03-02 23:24:01] masquerade (NAT) address: None
[I 14-03-02 23:24:01] passive ports: None
[I 14-03-02 23:24:01] use sendfile(2): False
test with lftp:
*NOTE, lftp syncs *contents* of local dir (rsync-like syntax doesn't create target dir):
+ lftp -e 'mirror -R -x ".*\.git.*" /tmp/loctest/; exit' -u user,12345 127.0.0.1
show dirs:
+ tree --noreport -a /tmp/srvtest /tmp/loctest
/tmp/srvtest
└── tempa1.txt
/tmp/loctest
├── .git
│ └── tempa2.txt
└── tempa1.txt
cleanup:
+ rm -rf /tmp/srvtest/tempa1.txt
*NOTE, specify lftp target dir explicitly (will be autocreated):
+ lftp -e 'mirror -R -x ".*\.git.*" /tmp/loctest /loctest ; exit' -u user,12345 127.0.0.1
show dirs:
+ tree --noreport -a /tmp/srvtest /tmp/loctest
/tmp/srvtest
└── loctest
└── tempa1.txt
/tmp/loctest
├── .git
│ └── tempa2.txt
└── tempa1.txt
cleanup:
+ sudo rm -rf /tmp/srvtest/loctest
*NOTE, ftpsync syncs *contents* of local dir (rsync-like syntax doesn't create target dir); also info mode -i is buggy (it puts, although it shouldn't):
*NOTE, ftpsync --ignoremask is for older unused code; use --exclude instead (but it is buggy; need to change in source)
+ /path/to/ftpsync/ftpsync -i -d '--exclude=.*\.git.*' /tmp/loctest ftp://user:[email protected]/
show dirs:
+ tree --noreport -a /tmp/srvtest /tmp/loctest
/tmp/srvtest
└── tempa1.txt
/tmp/loctest
├── .git
│ └── tempa2.txt
└── tempa1.txt
cleanup:
+ sudo rm -rf /tmp/srvtest/tempa1.txt
*NOTE, specify ftpsync target dir explicitly (will be autocreated):
+ /path/to/ftpsync/ftpsync -i -d '--exclude=.*\.git.*' /tmp/loctest ftp://user:[email protected]/loctest
show dirs:
+ tree --noreport -a /tmp/srvtest /tmp/loctest
/tmp/srvtest
└── loctest
└── tempa1.txt
/tmp/loctest
├── .git
│ └── tempa2.txt
└── tempa1.txt
cleanup:
+ sudo rm -rf /tmp/srvtest/loctest
+ sudo pkill -f ftpserver-cli.py
而且,这里是puttest.sh
脚本:
#!/usr/bin/env bash
set -x
# change these to match your installations:
FTPSRVCLIPATH="/path/to/pyftpdlib"
FTPSYNCPATH="/path/to/ftpsync"
{ echo "Recreate directories; populate loctest, keep srvtest empty:"; } 2>/dev/null
sudo rm -rf /tmp/srvtest /tmp/loctest
mkdir /tmp/srvtest
mkdir -p /tmp/loctest/.git
echo aaa > /tmp/loctest/tempa1.txt
echo aaa > /tmp/loctest/.git/tempa2.txt
{ echo "show dirs:"; } 2>/dev/null
tree --noreport -a /tmp/srvtest /tmp/loctest
{ echo -e "\n*NOTE, rsync can automatically figure out parent dir:"; } 2>/dev/null
rsync -a --exclude '*.git*' /tmp/loctest /tmp/srvtest/
{ echo "show dirs:"; } 2>/dev/null
tree --noreport -a /tmp/srvtest /tmp/loctest
{ echo "cleanup:"; } 2>/dev/null
rm -rf /tmp/srvtest/*
{ echo -e "\nStart a temporary ftp server:"; } 2>/dev/null
# https://askubuntu.com/questions/17084/how-do-i-temporarily-run-an-ftp-server
sudo bash -c "python $FTPSRVCLIPATH/ftpserver-cli.py --username=user --password=12345 --directory=/tmp/srvtest &"
sleep 1
{ echo "test with lftp:"; } 2>/dev/null
# see http://russbrooks.com/2010/11/19/lftp-cheetsheet
# The -R switch means "reverse mirror" which means "put" [upload].
{ echo -e "\n*NOTE, lftp syncs *contents* of local dir (rsync-like syntax doesn't create target dir):"; } 2>/dev/null
lftp -e 'mirror -R -x ".*\.git.*" /tmp/loctest/; exit' -u user,12345 127.0.0.1
{ echo "show dirs:"; } 2>/dev/null
tree --noreport -a /tmp/srvtest /tmp/loctest
{ echo "cleanup:"; } 2>/dev/null
rm -rf /tmp/srvtest/*
{ echo -e "\n*NOTE, specify lftp target dir explicitly (will be autocreated):"; } 2>/dev/null
lftp -e 'mirror -R -x ".*\.git.*" /tmp/loctest /loctest ; exit' -u user,12345 127.0.0.1
{ echo "show dirs:"; } 2>/dev/null
tree --noreport -a /tmp/srvtest /tmp/loctest
{ echo "cleanup:"; } 2>/dev/null
sudo rm -rf /tmp/srvtest/*
{ echo -e "\n*NOTE, ftpsync syncs *contents* of local dir (rsync-like syntax doesn't create target dir); also info mode -i is buggy (it puts, although it shouldn't):"; } 2>/dev/null
{ echo -e "\n*NOTE, ftpsync --ignoremask is for older unused code; use --exclude instead (but it is buggy; need to change ` 'exclude=s' => \$opt::exclude,` in source)"; } 2>/dev/null
$FTPSYNCPATH/ftpsync -i -d --exclude='.*\.git.*' /tmp/loctest ftp://user:[email protected]/
{ echo "show dirs:"; } 2>/dev/null
tree --noreport -a /tmp/srvtest /tmp/loctest
{ echo "cleanup:"; } 2>/dev/null
sudo rm -rf /tmp/srvtest/*
{ echo -e "\n*NOTE, specify ftpsync target dir explicitly (will be autocreated):"; } 2>/dev/null
$FTPSYNCPATH/ftpsync -i -d --exclude='.*\.git.*' /tmp/loctest ftp://user:[email protected]/loctest
{ echo "show dirs:"; } 2>/dev/null
tree --noreport -a /tmp/srvtest /tmp/loctest
{ echo "cleanup:"; } 2>/dev/null
sudo rm -rf /tmp/srvtest/*
sudo pkill -f ftpserver-cli.py
{ set +x; } 2>/dev/null
为的ncftp - 您使用“放-R”命令做一个递归目录上传? – DmitryK 2009-09-10 02:38:44
我确实 - 我认为问题的一部分是FTP是相当陈旧的..所以可能没有一个理想的解决方案 – codeinthehole 2009-09-10 03:29:52