Search code examples
linuxrsync

Simple RSync EXCLUDE option?


I want a simple and working (multiple) exclude option inside my rsync command. Lets say i will exclude a file and a directory:

  • /var/www/html/test.txt
  • /var/www/html/images/

What i did is:

rsync -avz --exclude="/var/www/html/test.txt" --exclude="/var/www/html/images/" /var/www/html [email protected]:/var/www

or

rsync -avz --exclude=/var/www/html/test.txt --exclude=/var/www/html/images/ /var/www/html [email protected]:/var/www

or

rsync -avz --exclude /var/www/html/test.txt --exclude /var/www/html/images/ /var/www/html [email protected]:/var/www

..

But however, the --exclude is NOT WORKING!
Everything is going out!

  • How to do it in this simple format please?

Note: I also don't want to use external exclusion list file. Just want all in one simple command.


Solution

  • i got it solved by myself after i've learned and tested many times. The real problem was the understandable (for me) --exclude option usage format.

    I don't know how others are doing but i just found out that:

    • "--exclude" path CAN NOT be the full absolute path!

    Because i was using the path(s) like: --exclude /var/www/html/text.txt which caused the thing DOES NOT work. So i used like:

    --exclude text.txt --exclude images/
    

    .. and it WORKS!