I'm trying to exlude all files of the directory cache/, except some specific files. Beside I want to Backup every other files in my source.
Content of source dir:
backup-test/
├── cache
│ ├── adodb
│ │ ├── .htaccess
│ │ ├── index.html
│ │ ├── test-adodb-1.html
│ │ ├── test-adodb-2.html
│ │ └── test-adodb-3.html
│ ├── .htaccess
│ ├── test-cache-1.html
│ ├── test-cache-2.html
│ └── test-cache-3.html
├── .htaccess
├── test-root-1.html
├── test-root-2.html
└── test-root-3.html
The files in cache/
I want to backup and shouldn't be excluded:
cache/index.html
cache/adodb/.htaccess
My command:
rsync -av --delete \
--include "cache/index.html" \
--include "cache/adodb/.htaccess" \
--exclude "cache/*" \
-e ssh "$SSH_REMOTE":"$BACKUP_SOURCE" "$BACKUP_DEST"
Output:
receiving incremental file list
backup-test/
backup-test/.htaccess
backup-test/test-root-1.html
backup-test/test-root-2.html
backup-test/test-root-3.html
backup-test/cache/
sent 174 bytes received 431 bytes 1,210.00 bytes/sec
total size is 35 speedup is 0.06
But it's not working as I expect. Rsync only backups an empty cache/ dir, without my included files. What can I do?