我目前的情況下,我有一臺服務器的渠道非常有限遞歸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