View previous topic :: View next topic |
Author |
Message |
leosgb Apprentice
Joined: 07 Mar 2006 Posts: 272 Location: Rio de Janeiro, Brazil
|
Posted: Wed Dec 12, 2007 7:32 am Post subject: rsync: how to send only specific files to remote host |
|
|
Hi,
I would like to make a backup of my website to another machine that I have using rsync. I read the man pages and I came up with this solution for my problem:
Code: |
rsync -vurpEog --delete --include="*.html" --include="*.med.jpg" --include="*.med.JPG" /pictures 192.168.1.220:/home/superman/pictures
|
But it copied all the files.
A description: I use "album" script to generate my website with pictures. The site is organized in a hierarchical form, year/month/day. There are files along the way. But I dont need to copy the original sized pictures since they are already stored in another media for backup. I just want to backup the website structure itself so I dont need to generate the page all over again (it can take quite some time for several pictures).
I would like to copy all ".html" files and all files in the last "tn/" folder. I also need to bring the whole tree structure intact.
So, say:
/pictures --> *.html
/pictures/2007/ --> *.html
/pictures/2007/January/ --> *.html
/pictures/2007/January/01_01/ --> *.html
/pictures/2007/January/01_01/ tn/ --> everything (*.html, *.JPG, *.jpg, *.med.jpg, *.med.JPG)
To finalize, the question is: how to command rsync to perform the above task? Is there a better way to do it?
Thank you very much for any help, |
|
Back to top |
|
|
JeliJami Veteran
Joined: 17 Jan 2006 Posts: 1086 Location: Belgium
|
Posted: Wed Dec 12, 2007 12:25 pm Post subject: |
|
|
Quote: | man rsync
...
--include=PATTERN don't exclude files matching PATTERN
... |
which probably means that include only works as an exception for excludes
maybe try something like
Code: | rsync --exclude="*" --include="*html" ... |
_________________ Unanswered Post Initiative | Search | FAQ
Former username: davjel |
|
Back to top |
|
|
leosgb Apprentice
Joined: 07 Mar 2006 Posts: 272 Location: Rio de Janeiro, Brazil
|
Posted: Fri Dec 14, 2007 3:02 am Post subject: |
|
|
Actually, when I tested it here with the flag it only copied the top folder (no files). Maybe you use either include or exclude... Do you know how to use rsync to transfer only a certain extension as I asked?
Thank you. |
|
Back to top |
|
|
JeliJami Veteran
Joined: 17 Jan 2006 Posts: 1086 Location: Belgium
|
Posted: Fri Dec 14, 2007 8:34 am Post subject: |
|
|
maybe it's easier to do something like this (warning: untested code):
Code: | $ tmp=$(mktemp)
$ find /pictures -type f \( -name "*html" -o -iname "*med.jpg" \) > ${tmp}
$ rsync ... --include-from="${tmp}" ...
$ rm ${tmp}
|
_________________ Unanswered Post Initiative | Search | FAQ
Former username: davjel |
|
Back to top |
|
|
ppurka Advocate
Joined: 26 Dec 2004 Posts: 3256
|
Posted: Fri Dec 14, 2007 11:16 pm Post subject: |
|
|
Tip: Use -n flag to rsync to "simulate" the file transfers. _________________ emerge --quiet redefined | E17 vids: I, II | Now using kde5 | e is unstable :-/ |
|
Back to top |
|
|
|