متكرر وضع الملفات إلى ملقم بعيد باستخدام FTP
-
05-07-2019 - |
سؤال
وأنا حاليا في الحالة التي يكون فيها لدي وصول محدود جدا إلى الخادم، ولكن تحتاج لتحميل وتنزيل كمية كبيرة من الملفات الموجودة داخل بنية دليل واحد. أنا لا يستطيعون الوصول SSH، لذلك لا يمكن استخدام SCP - ورسينك ليس خيارا إما للأسف
وأنا حاليا باستخدام ncftpput، وهو أمر عظيم ولكن يبدو أن بطيئة جدا (على الرغم من اتصال سريع).
هل هناك بديل / أفضل طريقة أنا يمكن أن ننظر إلى؟
(أرجو أن تقبلوا اعتذاري إذا كان هذا قد تم تغطيتها، لقد فعلت ذلك لبحث سريع قبل نشر لكنها لم تجد أي شيء أجاب على وجه التحديد سؤالي) م>
المحلول
وحاول استخدام LFTP: http://lftp.yar.ru/
وأو YAFC: http://yafc.sourceforge.net/index.php
نصائح أخرى
إذا كان لديك اتصال جيد، أود أن أوصي تركيب خادم بروتوكول نقل الملفات عن طريق GNOME أو KDE مديري الملف، وإلا باستخدام <لأ href = "http://curlftpfs.sourceforge.net/" يختلط = "نوفولو noreferrer" > CurlFtpFS . ثم يمكنك التعامل معها مثل مجلد آخر فقط.
وأنا لست على دراية ncftpput
. لFTP غير التبادلي، لقد استعملت دائما وحدة بيرل نت :: FTP - HTTP: //perldoc.perl.org/Net/FTP.html
وهذا سيكون أسرع لأنه يمكنك تسجيل الدخول، ثم القيام بكل عمليات نقل في وقت واحد (على ما يبدو من نظرة عابرة أن تقوم بتنفيذ ncftpput
مرة واحدة لكل ملف الحصول على / وضع).
وتذكر فقط أن استخدام NEVER تغيير اسم ASCII! هذا هو الافتراضي، لذلك الاستخدام:
$ftp->binary
وASCII تغيير اسم لابد أن يموت في نفس اطلاق النار مع الخلية التلقائي التوقيت-الترجمة.
وبما أنني دائما في نهاية المطاف وجود مشكلة مع هذا، أنا ما بعد ملاحظاتي هنا:
وشيء واحد أنا دائما الحصول على الخلط هو بناء الجملة. حتى دون وجود سيناريو اختبار bash
مما يخلق بعض الدلائل المؤقتة، ثم يبدأ خادم بروتوكول نقل الملفات المؤقتة، ويقارن rsync
(في وضع ملف محلي عادي، كما أنه لا يدعم بروتوكول نقل الملفات) مع lftp
وftpsync
.
والشيء هو - يمكنك استخدام rsync /path/to/local /path/to/remote/
، وسوف رسينك الرقم تلقائيا، التي تريد دليل فرعي local
أنشئت بموجب remote
. ومع ذلك، لlftp
أو ftpsync
لك على هل لديك لتحديد الدليل الهدف يدويا، كما هو الحال في ... /path/to/local /path/to/remote/local
(إذا لم يكن موجودا سيتم إنشاء ذلك).
ويمكنك العثور على ftpserver-cli.py
في كيف أقوم بتشغيل مؤقتا FTP الخادم؟ - اسأل أوبونتو . وftpsync
هنا هو: FTPsync (ولكن، لاحظ أنه من عربات التي تجرها الدواب، وانظر أيضا <أ href = ل "https://unix.stackexchange.com/questions/117797/search-grep-ftp-remote-filenames">Search/grep بروتوكول نقل الملفات أسماء الملفات عن بعد - يونكس و لينكس المكدس تبادل )؛
وهنا هو إخراج تقصير من السيناريو 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: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:
+ 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:12345@127.0.0.1/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: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, specify ftpsync target dir explicitly (will be autocreated):"; } 2>/dev/null
$FTPSYNCPATH/ftpsync -i -d --exclude='.*\.git.*' /tmp/loctest ftp://user:12345@127.0.0.1/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