logo

한국어

lftp 사용 방법

관리자 2017.02.05 16:54 조회 수 : 900

man page : http://lftp.tech/lftp-man.html



■ sftp 접속 예


lftp -u "<userid>,<password>" -e "cache off; set sftp:charset utf8; set sftp:auto-confirm yes; set net:timeout 60; set net:reconnect-interval-base 5; set net:max-retries 10; mirror -e -v /remote_dir /local_dir; exit" sftp://ssh.mysite.com:22



■ ftp 접속 예


lftp -u "<userid>,<password>" -e "cache off; set ftp:charset utf8; set net:timeout 60; set net:reconnect-interval-base 5; set net:max-retries 10; mirror -e -v /remote_dir /local_dir; exit" ftp://ftp.mysite.com



■ 설명


cache off; 캐쉬 안함

set sftp:charset utf8; sftp의 파일명을 utf8로 설정

set ftp:charset utf8; ftp의 파일명을 utf8로 설정

set net:timeout 60; 프로토콜 타임아웃 (초단위가 아님)

set net:reconnect-interval-base 5; 한번 접속 실패 후 5초간 쉰다.

set net:max-retries 10; 재접속 시도 횟수

mirror 옵션:

-c,      --continue                 continue a mirror job if possible

-e,      --delete                   delete files not present at remote site

         --delete-first             delete old files before transferring new ones

         --depth-first              descend   into  subdirectories  before  transferring

                                    files

         --scan-all-first           scan all directories recursively before transferring

                                    files

-s,      --allow-suid               set suid/sgid bits according to remote site

         --allow-chown              try to set owner and group on files

         --ascii                    use ascii mode transfers (implies --ignore-size)

         --ignore-time              ignore time when deciding whether to download

         --ignore-size              ignore size when deciding whether to download

         --only-missing             download only missing files

         --only-existing            download only files already existing at target

-n,      --only-newer               download only newer files (-c won't work)

         --upload-older             upload even files older than remote ones

         --transfer-all             transfer  all  files, even seemingly the same at the

                                    target site

         --no-empty-dirs            don't    create    empty    directories     (implies

                                    --depth-first)

-r,      --no-recursion             don't go to subdirectories

         --recursion=MODE           go to subdirectories on a condition

         --no-symlinks              don't create symbolic links

-p,      --no-perms                 don't set file permissions

         --no-umask                 don't apply umask to file modes

-R,      --reverse                  reverse mirror (put files)

-L,      --dereference              download symbolic links as files

         --overwrite                overwrite plain files without removing them first

         --no-overwrite             remove  and  re-create  plain files instead of over‐

                                    writing

-N,      --newer-than=SPEC          download only files newer than specified time

         --older-than=SPEC          download only files older than specified time

         --size-range=RANGE         download only files with size in specified range

-P,      --parallel[=N]             download N files in parallel

         --use-pget[-n=N]           use pget to transfer every single file

         --on-change=CMD            execute the command if anything has been changed

         --loop                     repeat mirror until no changes found

-i RX,   --include=RX               include matching files

-x RX,   --exclude=RX               exclude matching files

-I GP,   --include-glob=GP          include matching files

-X GP,   --exclude-glob=GP          exclude matching files

         --include-rx-from=FILE

         --exclude-rx-from=FILE

         --include-glob-from=FILE

         --exclude-glob-from=FILE   load include/exclude patterns from the file, one per

                                    line

-f FILE, --file=FILE                mirror   a   single  file  or  globbed  group  (e.g.

                                    /path/to/*.txt)

-F DIR,  --directory=DIR            mirror a single directory  or  globbed  group  (e.g.

                                    /path/to/dir*)

-O DIR,  --target-directory=DIR     target base path or URL

-v,      --verbose[=level]          verbose operation

         --log=FILE                 write lftp commands being executed to FILE

         --script=FILE              write lftp commands to FILE, but don't execute them

         --just-print, --dry-run    same as --script=-

         --max-errors=N             stop after this number of errors

         --skip-noaccess            don't try to transfer files with no read access.

         --use-cache                use cached directory listings

         --Remove-source-files      remove  source  files  after transfer (use with cau‐

                                    tion)

         --Remove-source-dirs       remove source files and directories  after  transfer

                                    (use  with  caution).   Top  level  directory is not

                                    removed if it's name ends with a slash.

         --Move                     same as --Remove-source-dirs

-a                                  same as --allow-chown --allow-suid --no-umask