LFTP 미러 포함 - 내가 포함하는 디렉터리 이외의 디렉터리도 포함합니다.

LFTP 미러 포함 - 내가 포함하는 디렉터리 이외의 디렉터리도 포함합니다.

내 질문: LFTP에 파일만 포함되도록 하는 방법그리고 목차포함되지 않은 원격 루트에서 추가 디렉토리를 다운로드하는 대신 또는 --include?--include-glob

일부 배경:

LFTP와 미러링을 사용하여 사이트 파일을 다운로드하고 있는데 특정 파일과 디렉터리만 다운로드하고 싶습니다. 따라서 원격 서버의 루트에서 실행되도록 LFTP에 대한 일부 포함 및 제외를 제공했습니다.

LFTP 담당자에 따르면 내가 이해한 바에 따르면 포함을 지정하면 지정한 모든 파일이 포함된 다음 포함 규칙에 제외가 적용된다는 것입니다. 이는 루트에 있는 파일에 대해 완벽하게 작동하며 포함되지 않은 파일은 다운로드하지 않습니다. 그러나 포함하도록 요청한 디렉터리뿐만 아니라 루트에 있는 모든 디렉터리를 다운로드합니다.

나는 사용하는 --include데 문제가 있다고 생각합니다 --include-glob... 두 가지 (glob 또는 regex) 중에서 무엇을 시도하더라도 포함 테이블에서 지정한 디렉토리 외부의 디렉토리를 다운로드하지 않도록 LFTP 미러를 얻을 수 없습니다. 내용물.

이것은 내 bash 스크립트입니다(bash 스크립트에는 약간 새로운 기능입니다).

#!/bin/bash

# Credentials
protocol="ftp" # ftp or sftp
host="host"
user="user"
pass="pass"
localcd="/path/to/localdir"
remotecd="/remotedir"

# Set up FTP URL
ftpurl="$protocol://$user:$pass@$host"

# Default includes - helps only include core files in root in case there are other random files
includes="--include-glob wp-admin/*" # other dirs are still being downloaded with these three
includes+=" --include-glob wp-content/*"
includes+=" --include-glob wp-includes/*"

includes+=" --include ^wp-.*\.php$"  # works just fine
includes+=" --include ^index.php$"   # works just fine
includes+=" --include ^xmlrpc.php$"   # works just fine

# Exclude hidden files/directories
excludes="--exclude-glob .*"
excludes+=" --exclude-glob .*/"

# LFTP sets
lftp_sets="set cmd:fail-exit yes;"
if [ "$protocol" == "ftp" ]
then
    lftp_sets+=" set ftp:ssl-allow no;"
fi

# Run the LFTP
lftp -e "$lftp_sets
open '$ftpurl';
lcd $localcd;
cd $remotecd;
mirror --continue --only-newer --delete --verbose=3 --no-perms --parallel=8 $includes $excludes"

나는 노력했다

includes="--include ^wp-.*/.**"

그리고

includes="--include ^wp-admin/.*"
includes+="--include ^wp-content/.*"
includes+="--include ^wp-includes/.*"

셀 수 없을 만큼 많은 변화가 있습니다. 4페이지 깊이의 LFTP 미러링에 대해 내가 검색한 모든 항목에는 보라색 링크가 있습니다. :(

답변1

작업 순서.

먼저 제외한 다음 포함해야 합니다.

이 예에서는 모든 항목을 제외하고 특정 폴더를 포함시킨 다음 포함된 폴더 내의 파일을 제외합니다.

mirror --exclude '.*' --exclude '.*/' --include 'v*-stable/' -X '*.src.rpm'

당신의 경우에는

mirror --continue --only-newer --delete --verbose=3 --no-perms --parallel=8 $excludes $includes"

관련 정보