rsync 迁移文件夹到指定文件夹 2023-07-13
作者:
阿然学编程 | 来源:发表于
2023-07-12 14:32 被阅读0次
#!/bin/bash
# 设置迁移的源文件夹的路径
SOURCE_FOLDER="/www/wwwroot/test01"
# 设置要迁移到目标文件夹的路径
DESTINATION_FOLDER="/www/wwwroot/test02"
# 是否压缩传输
IS_AVZ=true
# 设置要跳过的文件和文件夹
SKIP_DIRS=("log" "cache") # 要跳过的文件夹名称列表
SKIP_EXT=(".log" ".tmp") # 要跳过的文件扩展名列表
EXCLUDE_DIRS=""
for dir in "${SKIP_DIRS[@]}"; do
EXCLUDE_DIRS+="--exclude='$dir' "
done
EXCLUDE_EXT=""
for ext in "${SKIP_EXT[@]}"; do
EXCLUDE_EXT+="--exclude='*$ext' "
done
mkdir -p ${DESTINATION_FOLDER}
if [[ ${IS_AVZ} == true ]]; then
rsync -avzP --delete --progress --ignore-existing ${EXCLUDE_DIRS} ${EXCLUDE_EXT} "${SOURCE_FOLDER}/" ${DESTINATION_FOLDER}
else
rsync -avhP --delete --progress --ignore-existing ${EXCLUDE_DIRS} ${EXCLUDE_EXT} "${SOURCE_FOLDER}/" ${DESTINATION_FOLDER}
fi
echo "迁移完成"
exit
./qianyi.sh
本文标题:rsync 迁移文件夹到指定文件夹 2023-07-13
本文链接:https://www.haomeiwen.com/subject/kelpudtx.html
网友评论