Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Some command line syntax I don't know how to set, am a noob sometimes, sorry is that's obvious

Let's says I have the following path for all my assets :

/var/www/site/system/images/{image_id}/{format}/{file}.{extension}

Inside the {image_id} folder, I have multiple formats (original, medium, thumb, etc...).

I only want to import the /var/www/site/system/images/{image_id}/original folder, and keep the structure locally

scp -r username@server:/var/www/site/system/images/*/original ~/Site/site/system/images

This one does get it all, but all the files end up in the same and unique folder, no structure.

I'd like to keep the structure. Is there something to do for it ?

share|improve this question
1  
You can use rsync and exclude medium and thumb –  coincoin Oct 13 '12 at 11:31
    
Thx Eric, you put me on the way; exclude was the thing. Always end up on some slicehost's clean explanations in the end –  Ben Oct 13 '12 at 21:10

1 Answer 1

up vote 4 down vote accepted

Use rsync, becasue scp is limited in many ways.

To get you started here is an example:

rsync genja.org:/home/www/*/html/ /tmp/dest/html/ -avin 
host: genja.lan 
receiving incremental file list
created directory /tmp/dest/html
cd+++++++++ ./
>f+++++++++ tabs.html
cd+++++++++ borders/
cd+++++++++ borders/border-radius/
>f+++++++++ borders/border-radius/border-radius.htc
>f+++++++++ borders/border-radius/border-radius.html
cd+++++++++ borders/css-tricks.com/
(...)

The important options are -a and -v if you want to see what is going on. If you add -in then the command will only pretend that it is running, so you can review what will get copied and where.

There is a subtle difference in how trailing slashed are treated. Just make sure you include a trailing slash on both the destination and the source folders to begin with.

share|improve this answer
    
The structure is not maintained in that case, a last in my case; all the files get downloaded in the same folder –  Ben Oct 13 '12 at 21:13
    
Then you need to copy from a higher level folder and use --exclude for what you don't need. –  Ярослав Рахматуллин Oct 13 '12 at 21:31
    
--exclude was the thing –  Ben Oct 13 '12 at 21:42
    
Okay, I'm not sure to open a new question for this. But I see you there. I need to know what has just been synced in order to process the files just received each time. How can I cleanly save the rsync output somewhere ? –  Ben Oct 13 '12 at 21:46
    
I have never used this options, but there is --log-file=FILE for rsync which can be customized. You can look into that. .....The simple thing to do would be: rsync /source /destination -av 2>&1 > /tmp/rsync-out.txt . This will save all the output and errors into /tmp/rsync-out.txt –  Ярослав Рахматуллин Oct 13 '12 at 21:51

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.