Results 1 to 8 of 8

Thread: rsync - including only certain extensions

  1. #1
    Join Date
    Aug 2007
    Location
    Massachusetts
    Beans
    16

    Smile rsync - including only certain extensions

    Hi,

    I run some backup scripts using rsync and after compression the backups are still over 50gb. I'd like to cut that down and to do that I want to include ONLY files with certain extensions (eg every file with a .bmp/.mp3/.pst etc.. extension)

    My question is that if i use --include will it exclude all other files or will I have to use a combination of the --include and --exclude. Maybe there's an even easier way of doing it.

    Any help you could give would be awesome.

    Thanks a lot!

  2. #2
    Join Date
    Jun 2007
    Beans
    290
    Distro
    Kubuntu 9.04 Jaunty Jackalope

    Re: rsync - including only certain extensions

    I'd use the
    Code:
    --include-from=FILE
    option. Put the regular expressions of the files you want to backup, one per line, into a file and use that filename in the option. It may a bit of experimenting to get the names correct, but if you're trying to only include a certain subset of names, this will be the easiest to use (and maintain).
    E. A. (Ed) Graham, Jr.
    Linux User #28251
    Professional Java Geek

  3. #3
    Join Date
    Aug 2007
    Location
    Massachusetts
    Beans
    16

    Re: rsync - including only certain extensions

    Quote Originally Posted by txcrackers View Post
    I'd use the
    Code:
    --include-from=FILE
    option. Put the regular expressions of the files you want to backup, one per line, into a file and use that filename in the option. It may a bit of experimenting to get the names correct, but if you're trying to only include a certain subset of names, this will be the easiest to use (and maintain).
    Thanks for the reply. I hate to sound noobish but do you have an example of the kind of expression I would use?

    Also, will the include file force rsync to ONLY transfer files in the file?

  4. #4
    Join Date
    Aug 2007
    Location
    Massachusetts
    Beans
    16

    Re: rsync - including only certain extensions

    Bumped.

  5. #5
    Join Date
    May 2008
    Beans
    5
    Distro
    Ubuntu Karmic Koala (testing)

    Re: rsync - including only certain extensions

    What you need is indeed a combination of --include and --exclude arguments. For example the following will replicate only mp3 files in a directory named source, or any of its subdirectories, to a directory named target:

    Code:
    rsync -a --include '*/' --include '*.mp3' --exclude '*' source/ target/
    This will (1) include any directory or subdirectory, whatever its contents, (2) include all files with an mp3 extension, and (3) exclude all other files. Any number of other file types can be included by adding their one include pattern for each before the --exclude, e.g. --include '*.bmp'.

  6. #6
    Join Date
    Aug 2006
    Beans
    5

    Smile Re: rsync - including only certain extensions

    Thanks!

  7. #7
    Join Date
    May 2007
    Beans
    9

    Re: rsync - including only certain extensions

    Quote Originally Posted by thuerrschmidt View Post
    What you need is indeed a combination of --include and --exclude arguments. For example the following will replicate only mp3 files in a directory named source, or any of its subdirectories, to a directory named target:

    Code:
    rsync -a --include '*/' --include '*.mp3' --exclude '*' source/ target/
    This will (1) include any directory or subdirectory, whatever its contents, (2) include all files with an mp3 extension, and (3) exclude all other files. Any number of other file types can be included by adding their one include pattern for each before the --exclude, e.g. --include '*.bmp'.
    Thanks a lot! I've been searching for this information all over the internet and rsync's manpage and couldn't find it

  8. #8
    Join Date
    Jul 2007
    Location
    Magic City of the Plains
    Beans
    Hidden!
    Distro
    Xubuntu 16.10 Yakkety Yak

    Re: rsync - including only certain extensions

    Closed, necromancy.

Tags for this Thread

Bookmarks

Posting Permissions

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