FTP를 사용하여 파일을 원격 서버에 재귀 적으로 넣습니다
-
05-07-2019 - |
문제
현재 서버에 대한 액세스가 매우 제한되어 있지만 단일 디렉토리 구조에 포함 된 상당한 양의 파일을 업로드하고 다운로드 해야하는 상황에 처해 있습니다. SSH 액세스 권한이 없으므로 SCP를 사용할 수 없으며 RSYNC는 불행히도 옵션이 아닙니다.
나는 현재 NCFTPPUT를 사용하고 있습니다. 이것은 훌륭하지만 매우 느린 것 같습니다 (빠른 연결에도 불구하고).
내가 살펴볼 수있는 대안 / 더 나은 방법이 있습니까?
(이것이 다루어 졌다면 사과를 받아들이십시오. 게시하기 전에 빠른 검색을했지만 내 질문에 구체적으로 대답 한 것을 찾지 못했습니다)
해결책
LFTP를 사용해보십시오 :http://lftp.yar.ru/
다른 팁
연결이 양호한 경우 GNOME 또는 KDE 파일 관리자를 통해 FTP 서버를 장착하거나 사용하는 것이 좋습니다. curlftpfs. 그런 다음 다른 폴더처럼 취급 할 수 있습니다.
나는 익숙하지 않다 ncftpput
. 상호 관계가 아닌 FTP의 경우 항상 Perl Net :: FTP 모듈을 사용했습니다. http://perldoc.perl.org/net/ftp.html
로그인 할 수 있기 때문에 더 빠릅니다. 그런 다음 모든 전송을 한 번에 수행합니다 (실행하는 커서 한 눈에 보입니다. ncftpput
각 파일마다 한 번 가져 오기/풋).
ASCII Mangling을 절대 사용하지 마십시오! 이것은 기본값이므로 사용하십시오.
$ftp->binary
ASCII Mangling은 MySQL Automatic-Timezone-Interpreting과 같은 화재로 죽어야합니다.
나는 항상 이것에 문제가 있기 때문에 여기에 내 메모를 게시하겠습니다.
내가 항상 혼동하는 것은 구문입니다. 그래서 아래에는 a가 있습니다 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
(존재하지 않으면 생성됩니다).
당신은 찾을 수 있습니다 ftpserver-cli.py
안에 FTP 서버를 일시적으로 실행하려면 어떻게해야합니까? - 우분투에게 물어보세요; 그리고 ftpsync
여기에: ftpsync (그러나 그것은 버그가 많다는 것을 주목하십시오. 또한 참조하십시오. 검색/grep FTP 원격 파일 이름 -NIX & Linux 스택 교환);
다음은 단축 출력입니다 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