Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 :


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
You can use rsync and exclude medium and thumb – user130370 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
up vote 4 down vote accepted

Use rsync, becasue scp is limited in many ways.

To get you started here is an example:

rsync*/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/
>f+++++++++ borders/border-radius/border-radius.html
cd+++++++++ borders/

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


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.