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?
2 Answers
Assuming your shell is bash,
shopt -s extglob mv !(fcgi-bin|public_html|awstats|cgi-bin|...) public_html - Thanks for the tips mates! It worked like charm. Just a little correction, "shopts" didn't worked it's "shopt".. typo :)Minhaj– Minhaj2011-10-25 07:49:04 +00:00Commented Oct 25, 2011 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.
- 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..Minhaj– Minhaj2011-10-25 07:52:24 +00:00Commented Oct 25, 2011 at 7:52