How to exclude all files except specific files with rsync?
I'm trying to only backup specific files with rsync, to exclude all files , except some specific files, namely the .md files, and solutions from all these pages didn't work for me:
- https://velenux.wordpress.com/2017/01/09/how-to-exclude-everything-except-a-specific-pattern-with-rsync/
- https://superuser.com/questions/1637543/how-to-specify-no-files-except-these-extensions-in-rsync
- https://serverfault.com/questions/1063730/rsync-exclude-all-files-in-dir-except-specific-files
$ rsync -vua --exclude="*" --include="*.md" ../log ./
sending incremental file list
sent 19 bytes received 12 bytes 62.00 bytes/sec
total size is 0 speedup is 0.00
$ rsync -vua --include="*.md" --exclude="*" ../log ./
sending incremental file list
sent 19 bytes received 12 bytes 62.00 bytes/sec
total size is 0 speedup is 0.00
$ du -sh ../log
1016M ../log
$ apt-cache policy rsync
rsync:
Installed: 3.2.7-0ubuntu0.22.04.2
Candidate: 3.2.7-0ubuntu0.22.04.2
Version table:
*** 3.2.7-0ubuntu0.22.04.2 500
500 http://ca-toronto-1-ad-1.clouds.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages
100 /var/lib/dpkg/status
3.2.3-8ubuntu3 500
500 http://ca-toronto-1-ad-1.clouds.archive.ubuntu.com/ubuntu jammy/main amd64 Packages