我有以下远程文件夹/文件结构:
/home/user/backup/siteA/regionA/data.sql
/home/user/backup/siteA/regionA/data.clean.sql
/home/user/backup/siteA/regionA/data.lite.sql
/home/user/backup/siteA/regionA/files/
/home/user/backup/siteA/regionB/data.sql
/home/user/backup/siteA/regionB/data.clean.sql
/home/user/backup/siteA/regionB/data.lite.sql
/home/user/backup/siteA/regionB/files/
/home/user/backup/siteA/regionC/data.sql
/home/user/backup/siteA/regionC/data.clean.sql
/home/user/backup/siteA/regionC/data.lite.sql
/home/user/backup/siteA/regionC/files/
/home/user/backup/siteA/regionD/data.sql
/home/user/backup/siteA/regionD/data.clean.sql
/home/user/backup/siteA/regionD/data.lite.sql
/home/user/backup/siteA/regionD/files/
/home/user/backup/siteB/regionA/data.sql
/home/user/backup/siteB/regionA/data.clean.sql
/home/user/backup/siteB/regionA/data.lite.sql
/home/user/backup/siteB/regionA/files/
/home/user/backup/siteB/regionB/data.sql
/home/user/backup/siteB/regionB/data.clean.sql
/home/user/backup/siteB/regionB/data.lite.sql
/home/user/backup/siteB/regionB/files/
/home/user/backup/a-script.sh
/home/user/backup/backup.log
/home/user/backup/siteC
...
...
我需要 rsync*.clean.sql
并*.lite.sql
从 siteA 到本地类似的结构,例如:
/var/data/dbs/siteA/regionA/data.clean.sql
/var/data/dbs/siteA/regionA/data.lite.sql
我似乎无法让rsyn
c 包含/排除正确的东西。我在尝试:
/usr/bin/rsync --archive --del --verbose --verbose --compress --progress --exclude-from=excludes.txt --rsh='ssh -q' --dry-run user@remote:/home/user/backup/siteA /var/data/dbs/siteA
我的 excludes.txt 包含:
+ *.clean.sql
+ *.lite.sql
- *
但是我只是得到:
receiving incremental file list
[sender] hiding directory siteA because of pattern *
我有一个脚本可以在每个站点区域的基础上执行此操作,但不能作为“整体”执行此操作。我尝试在排除列表中添加星号和斜线,但似乎找不到正确的组合。有什么建议么?
更新
我有更好的结果
/usr/bin/rsync --archive --del --compress --progress --exclude-from=excludes.txt --rsh='ssh -q' user@remote:/home/user/backup/siteA /var/data/dbs/siteA
与 excludes.txt
+ */
+ *.clean.sql
+ *.lite.sql
- *
但是,这也会解析所有文件夹的内容(尽管跳过/排除它们),这会减慢它的速度(并用大量的目录列表污染 rsync 输出)。
是否有“最大深度”参数?!