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

I made a terrible mistake while move sites of one server to another. We created virtualhosts in the new server using virtualmin. But while restoring files from old server to new server, I mistakenly copied all files in "/home/VIRTUALHOSTS-NAME/" instead of "/home/VIRTUALHOSTS-NAME/public_html". Now I had to move all files from the home directory of the virtualhosts to the public_html directory except few default folders like: fcgi-bin, public_html, awstats,cgi-bin etc. Can this be automated with a shell script or any command with pipe?

share|improve this question
up vote 5 down vote accepted

Assuming your shell is bash,

shopt -s extglob
mv !(fcgi-bin|public_html|awstats|cgi-bin|...) public_html
share|improve this answer
Thanks for the tips mates! It worked like charm. Just a little correction, "shopts" didn't worked it's "shopt".. typo :) – Saif Oct 25 '11 at 7:49

Yes, rsync is able to do this out-of-the-box. There are many command line parameters to tweak it as you want it.

Assuming you are on an Operating System where rsync is available.

share|improve this answer
Well, yes that could be done with rsync but it'll take lots of time to write the script.. because the folder structure was different in the source machine.. I've done rsync on the 2nd server which used as failover.. – Saif Oct 25 '11 at 7:52

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.