
その Web サイトで lftp に提供された構文の説明が混乱しています。
-x RX, --exclude=RX exclude matching files
-X GP, --exclude-glob=GP exclude matching files
ミラーリングプロセスから特定のファイルをどのように除外しますか?
--exclude filea --exclude fileb --exclude filec
--exclude filea fileb filec
--exclude ./filea ./fileb filec
Googleでも検索しましたが、除外の例を見つけることができませんか? !
答え1
-x RX
と一致するRegular eXpression
場合egrep()
と一致する-X GX
場合Glob Pattern
は、基本的に一般的な文字一致です。*。たとえば、
# To exclude .svn directories use:
mirror -e -x ^\.svn/$ /myhome/ /elsewhere
# To exclude all folders starting with a dot:
mirror -e -x /\..+/$ /myhome/ /elsewhere
# To exclude all *.bin AND *.so files:
mirror -e -X *.bin -X *.so /myhome/ /elsewhere
ご覧のとおり、私が知っている限りリストを提供できないため、各ファイルタイプに-Xを使用する必要があります。
答え2
私の(検証され有効な)コメントは次のとおりです。
含まれていません:
- 隠しフォルダとファイル(.gitも含む)
- scripts/ - フォルダ(私は保存します
deploy.sh
) - さまざまなアクティブ/リスク/準備/表面ファイル(注:パイプ|演算子make(her:内部、一重引用符)を持つregExpが必要です)
配布.sh
#!/usr/bin/env bash
# switch to script parent dir == project dir
cd "$(dirname $(dirname $0))"
if ! [[ "$PWD" =~ \/myproject$ ]]; then
echo "you are not in the myproject folder!"
exit 1
fi
# a (relatively) good place to store your credits (outside repo, ...)
read FTPCREDITS < ~/.ssh/creds/FTPCREDITS
if [ -z "$FTPCREDITS" ]; then
echo "Could NOT read credits. Exiting."
exit 2
fi
さて、最後に:
lftp -c "set ftp:list-options -a; \
open $FTPCREDITS; \
lcd .; \
mirror --reverse --delete --use-cache --verbose --allow-chown \
--allow-suid --no-umask --parallel=2 \
-x '^\.' -x '^script\/' \
-x '\.(psd|rev|log|cmd|bat|pif|scr|exe|c?sh|reg|vb?|ws?)$' \
; \
close -a;"
テストに適しています:
--dry-run
(自然)./script/deploy.sh | grep Transferring
その他の関連コンテンツを見る