Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
rsync: how to send only specific files to remote host
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
leosgb
Apprentice
Apprentice


Joined: 07 Mar 2006
Posts: 272
Location: Rio de Janeiro, Brazil

PostPosted: Wed Dec 12, 2007 7:32 am    Post subject: rsync: how to send only specific files to remote host Reply with quote

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
View user's profile Send private message
JeliJami
Veteran
Veteran


Joined: 17 Jan 2006
Posts: 1086
Location: Belgium

PostPosted: Wed Dec 12, 2007 12:25 pm    Post subject: Reply with quote

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
View user's profile Send private message
leosgb
Apprentice
Apprentice


Joined: 07 Mar 2006
Posts: 272
Location: Rio de Janeiro, Brazil

PostPosted: Fri Dec 14, 2007 3:02 am    Post subject: Reply with quote

Actually, when I tested it here with the
Quote:
exclude
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
View user's profile Send private message
JeliJami
Veteran
Veteran


Joined: 17 Jan 2006
Posts: 1086
Location: Belgium

PostPosted: Fri Dec 14, 2007 8:34 am    Post subject: Reply with quote

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
View user's profile Send private message
ppurka
Advocate
Advocate


Joined: 26 Dec 2004
Posts: 3256

PostPosted: Fri Dec 14, 2007 11:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum