Find the answer to your Linux question:
Results 1 to 3 of 3
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    rsync - including only certain extensions


    I run some backup scripts using rsync and in order to cut down on the filesize, I only want to backup the files with certain extensions (ie .bmp/.jpg/.css etc...).

    My question is that if I use --include *.bmp will I have to use --exclude *.* (or something) too? After reading the man pages I'm just a little confused!

    Does anyone know of a way to get this done?

    Thanks a lot

  2. #2
    Linux Newbie raghaven.kumar's Avatar
    Join Date
    Mar 2008
    Bangalore, India
    i would recommend scp cause its secure.

  3. #3
    Just Joined!
    Join Date
    Sep 2007
    Lafayette, IN
    Quote Originally Posted by raghaven.kumar View Post
    i would recommend scp cause its secure.
    For local copying, it doesn't matter. For remote copying you can tell rsync to use SSH with the -e flag, like this:
    rsync -e /bin/ssh
    To answer the original question, you can do something like this:
    rsync -av  --include="*yes" --exclude="*" -n 1/ 2/
    In my example, the directory 1 has files named a.yes,, b.yes,, etc. When the above command is run, only the *yes files get copied. Take note: rsync cares what comes first. If you put the exclude first, nothing gets copied.

  4. $spacer_open

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts