Find the answer to your Linux question:
Results 1 to 3 of 3
Hey! 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...). ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Apr 2008
    Posts
    1

    rsync - including only certain extensions


    Hey!

    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
    Location
    Bangalore, India
    Posts
    209
    i would recommend scp cause its secure.

  3. #3
    Just Joined!
    Join Date
    Sep 2007
    Location
    Lafayette, IN
    Posts
    83
    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:
    Code:
    rsync -e /bin/ssh
    To answer the original question, you can do something like this:
    Code:
    rsync -av  --include="*yes" --exclude="*" -n 1/ 2/
    In my example, the directory 1 has files named a.yes, a.no, b.yes, b.no, 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.

Posting Permissions

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