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

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

2 Answers 2

up vote 4 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

 
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.