<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ali Qureshi&#039;s Blog &#187; Apache server tricks</title>
	<atom:link href="http://www.parorrey.com/blog/tag/apache-server-tricks/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.parorrey.com/blog</link>
	<description>random bits on web development</description>
	<lastBuildDate>Thu, 09 Sep 2010 10:45:49 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
	<atom:link rel='hub' href='http://www.parorrey.com/blog/?pushpress=hub'/>
		<item>
		<title>Copying files from remote server to another server through SSH</title>
		<link>http://www.parorrey.com/blog/web-hosting/copying-files-from-remote-server-to-another-server-through-ssh/</link>
		<comments>http://www.parorrey.com/blog/web-hosting/copying-files-from-remote-server-to-another-server-through-ssh/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 11:00:28 +0000</pubDate>
		<dc:creator>Ali</dc:creator>
				<category><![CDATA[Web Hosting]]></category>
		<category><![CDATA[Webmaster Tasks]]></category>
		<category><![CDATA[Apache server tricks]]></category>
		<category><![CDATA[SSH commands]]></category>

		<guid isPermaLink="false">http://www.parorrey.com/blog/?p=68</guid>
		<description><![CDATA[For any webmaster, switching web server is a nightmare, especially when there is large number of files to move to a new server. After some bitter experiences, I have found out following methods to move your data files and database quickly and painlessly from one server to another. I’m sure these SSH commands will save [...]


Related posts:<ol><li><a href='http://www.parorrey.com/blog/php-development/how-to-unzip-files-on-remote-server-using-php-script/' rel='bookmark' title='Permanent Link: how to unzip files on remote server using PHP script'>how to unzip files on remote server using PHP script</a></li>
<li><a href='http://www.parorrey.com/blog/webmaster-tasks/backup-your-mysql-databases-automatically-with-cron-job/' rel='bookmark' title='Permanent Link: Backup your MySQL databases automatically with cron job'>Backup your MySQL databases automatically with cron job</a></li>
<li><a href='http://www.parorrey.com/blog/project-management/ten-step-guide-to-install-redmine-project-management-application/' rel='bookmark' title='Permanent Link: Ten Step Guide to Install Redmine project management application'>Ten Step Guide to Install Redmine project management application</a></li>
</ol>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.parorrey.com%2Fblog%2Fweb-hosting%2Fcopying-files-from-remote-server-to-another-server-through-ssh%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.parorrey.com%2Fblog%2Fweb-hosting%2Fcopying-files-from-remote-server-to-another-server-through-ssh%2F&amp;source=parorrey&amp;style=normal" height="61" width="50" /><br />
			</a>
		</div>
<p>For any webmaster, switching web server is  a nightmare, especially when there is large number of files to move to a new  server. After some bitter experiences, I have found out following methods to  move your data files and database quickly and painlessly from one server to  another. I’m sure these SSH commands will save your day.</p>
<p>  These methods will copy/get that data files  and database from your old server say <strong>Server  A</strong> to new server say <strong>Server B</strong> without downloading anything to your PC. This way you will save some bandwidth  and valuable time, and lot of anxious moments while your huge files are being  uploaded when after lot of waiting and whining all you see is ‘script timed out’  message.</p>
<p>  I’m assuming here that you have SSH access  to your servers.</p>
<p>  For data files, what I usually do is that I  tar the files because file permissions are preserved and kept intact on the new  server. First login through SSH to the <strong>Server  A </strong>where your files are located. </p>
<p>  Here are the commands: </p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span>username-of-your-account<span style="color: #000000; font-weight: bold;">/</span>public_html
  <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-cvf</span> backup-website.tar .<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>Once it’s done, go to your new server say <strong>Server B</strong> and login through SSH: </p>
<p>  Here are the commands: </p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">  <span style="color: #7a0874; font-weight: bold;">cd</span> <span style="color: #000000; font-weight: bold;">/</span>home<span style="color: #000000; font-weight: bold;">/</span> username-of-your-account <span style="color: #000000; font-weight: bold;">/</span>public_html
  <span style="color: #c20cb9; font-weight: bold;">wget</span> your-old-domain.com<span style="color: #000000; font-weight: bold;">/</span>backup-website.tar
  <span style="color: #c20cb9; font-weight: bold;">tar</span> <span style="color: #660033;">-xvf</span> backup-website.tar</pre></div></div>

<p>  That’s it. One caveat here for extraction  of tar file if you are logged in as root user. If you have any cPanel or  HSphere panel available, you should use that to extract the tar file. </p>
<p>  So either log in with your account user  name or If you do extract the tar file with the root user, you probably want to  check and make sure the correct owner and group are on your files you just extracted.  You can check to see what they are by typing: </p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-la</span></pre></div></div>

<p>  If the owner or group is wrong you can run  this to change the owner: </p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">chown</span> <span style="color: #660033;">-R</span> owner.group .<span style="color: #000000; font-weight: bold;">/</span></pre></div></div>

<p>owner.group should be replaced with the  owner name you want and the group name you want. This will recursively go  through all your files and directories and changed them to the correct owner  and group. One warning here, this command can change the owner and group for  all of your files located on new server and can bring down your new server  before even getting started. If the file permissions are not correct, you will  see Forbidden error so only run this command “c<strong>hown“</strong> if you are really sure what you are doing. So be very careful  for this command.</p>
<p>  It would be far better and safer to extract  the tar file using cPanel File Manager or logging in SSH with the hosting account  name.</p>
<p>  Hope that helps.</p>
<p>  Cheers!</p>
<div style="padding-top:0px;padding-right:0px;padding-bottom:0px;padding-left:0px;;">
										<iframe
											style="height:25px !important; border:none !important; overflow:hidden !important; width:340px !important;" frameborder="0" scrolling="no" allowTransparency="true"
											src="http://www.linksalpha.com/social?link=http%3A%2F%2Fwww.parorrey.com%2Fblog%2Fweb-hosting%2Fcopying-files-from-remote-server-to-another-server-through-ssh%2F&fc=333333&fs=arial&fblname=like">
										</iframe>
										</div>

<p>Related posts:<ol><li><a href='http://www.parorrey.com/blog/php-development/how-to-unzip-files-on-remote-server-using-php-script/' rel='bookmark' title='Permanent Link: how to unzip files on remote server using PHP script'>how to unzip files on remote server using PHP script</a></li>
<li><a href='http://www.parorrey.com/blog/webmaster-tasks/backup-your-mysql-databases-automatically-with-cron-job/' rel='bookmark' title='Permanent Link: Backup your MySQL databases automatically with cron job'>Backup your MySQL databases automatically with cron job</a></li>
<li><a href='http://www.parorrey.com/blog/project-management/ten-step-guide-to-install-redmine-project-management-application/' rel='bookmark' title='Permanent Link: Ten Step Guide to Install Redmine project management application'>Ten Step Guide to Install Redmine project management application</a></li>
</ol></p>]]></content:encoded>
			<wfw:commentRss>http://www.parorrey.com/blog/web-hosting/copying-files-from-remote-server-to-another-server-through-ssh/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
