<?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>Kerry D. Wong &#187; Backup</title>
	<atom:link href="http://www.kerrywong.com/tag/backup/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kerrywong.com</link>
	<description></description>
	<lastBuildDate>Fri, 03 Sep 2010 00:51:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Simple WordPress Standby Server</title>
		<link>http://www.kerrywong.com/2009/02/08/simple-wordpress-standby-server/</link>
		<comments>http://www.kerrywong.com/2009/02/08/simple-wordpress-standby-server/#comments</comments>
		<pubDate>Mon, 09 Feb 2009 02:52:52 +0000</pubDate>
		<dc:creator>kwong</dc:creator>
				<category><![CDATA[Linux/BSD]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Server]]></category>
		<category><![CDATA[Standby]]></category>
		<category><![CDATA[VMWare]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://www.kerrywong.com/?p=535</guid>
		<description><![CDATA[I mentioned in one previous post on how to do a physical to VM backup using simple Linux command. The method works pretty well as long as the kernel versions are kept in sync. But for my Web server running WordPress,this backup method seemed to be an overkill. I use the following method to setup [...]]]></description>
			<content:encoded><![CDATA[<p>I mentioned in one previous post on how to do a<a href="/2007/10/05/a-physical-to-vm-backup-strategy-for-ubuntu-server/"> physical to VM backup</a> using simple Linux command. The method works pretty well as long as the kernel versions are kept in sync. <span id="more-535"></span></p>
<p>But for my Web server running WordPress,this backup method seemed to be an overkill. I use the following method to setup a standby WordPress server (can be either a VM or a physical machine). The backup server is always running and it&#8217;s content is synced up with the production server. In the event of a production server failure, all I need to do is to re-route the port 80 traffic to the standby server, which can be achieved in a matter of seconds.</p>
<p>To setup the standby server, I first installed Ubuntu server 8.04.1 (the same version as on my production server, with LAMP), and copied the WordPress content over (of course, most of the configurations need to be identical to the production server as well). To sync up the database content and the custom contents (e.g. uploaded images), the following command is scheduled to run on the server on a daily basis, which essentially backs up the content database:</p>
<div>mysqldump <em>[wordpress db name]</em> -p<em>[password]</em> &gt;&nbsp; /<em>[backup directory root]</em>/<em>[backup file name]</em></div>
<p>&nbsp;</p>
<p>on the standby server, the following commands are scheduled using cron daily to pick up the changes in production environment:</p>
<div>rcp <em>[user name]</em>@<em>[production server]</em>:<em>[backup directory root]</em>/<em>[backup file name]</em> ./dbbackup/</div>
<div>mysql -u<em>[user name]</em> -p<em>[password]</em> <em>[wordpress db name]</em> &lt; ./dbbackup/<em>[backup file name]</em></div>
<div>rcp -r <em>[user name]</em>@<em>[production server]</em>:/var/www/<em>[wp installation dir]</em>/wp-content/uploads /var/www/blog/wp-content</div>
<p>&nbsp;</p>
<p>The above commands essentially restore the production database snapshot onto the standby server and sync up the custom contents.</p>
<p>One benefit of this hot sync technique is that the standby server is always live and can be tested readily by changing the host entry in /etc/hosts to point the production url to the standby server.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.kerrywong.com/2009/02/08/simple-wordpress-standby-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Physical to VM Backup Strategy for Ubuntu Server</title>
		<link>http://www.kerrywong.com/2007/10/05/a-physical-to-vm-backup-strategy-for-ubuntu-server/</link>
		<comments>http://www.kerrywong.com/2007/10/05/a-physical-to-vm-backup-strategy-for-ubuntu-server/#comments</comments>
		<pubDate>Fri, 05 Oct 2007 10:42:38 +0000</pubDate>
		<dc:creator>kwong</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Backup]]></category>
		<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[Ubuntu Server]]></category>
		<category><![CDATA[VMWare]]></category>

		<guid isPermaLink="false">http://www.kerrywong.com/2007/10/05/a-physical-to-vm-backup-strategy-for-ubuntu-server/</guid>
		<description><![CDATA[One benefit of using a Linux environment is that the whole system back up is extremely easy. In fact, if you are doing the backups and restores for the same machine (which is usually the case), you only need to use the TAR command (see details) and no special software is needed. However, sometimes it [...]]]></description>
			<content:encoded><![CDATA[<p>One benefit of using a Linux environment is that the whole system back up is extremely easy.<span id="more-226"></span> In fact, if you are doing the backups and restores for the same machine (which is usually the case), you only need to use the TAR command (see <a href="https://help.ubuntu.com/community/BackupYourSystem/TAR">details</a>) and no special software is needed.</p>
<p>However, sometimes it is desirable to have a standby instance of the machine. For example, in a production environment, if a standby server is hot-synced with the production server then in the event of a production server failure, the standby server can kick in right away and the downtime can be reduced to as little as a couple of minutes. Whereas if a system restore is required, the production server has to be re-imaged and that can take significantly longer.</p>
<p>Fortunately, it is relatively easy to achieve this goal. In this post I will show you how to backup a Ubuntu Server (7.04) system to a Virtual Server. It only requires a few more steps then the plain vanilla TAR backup/restore.</p>
<ul>
<li><strong>Backup</strong></li>
</ul>
<blockquote>
<p>The backup command is almost identical to the command used in a standard backup (e.g. the backup is used to restore to the same server). Because the backup machine might not have the same physical specs as the machine where we perform the backup, we need to exclude a few more items. Particularly, <br />
<strong>/dev, /etc/fstab, /etc/hostname, /etc/iftab </strong>might be different on the backup machine and we need to be careful not to overwrite them when restoring. An example of the TAR command used for backup a system is listed here:</p>
</blockquote>
<blockquote><blockquote>tar -czf /mnt/backup/sysbackup/backup.tgz &#8211;exclude=/proc &#8211;exclude=/dev &#8211;exclude=/lost+found &#8211;exclude=/mnt &#8211;exclude=/sys &#8211;exclude=/cdrom &#8211;exclude=/etc/fstab &#8211;exclude=/etc/hostname &#8211;exclude=/etc/iftab / 
</p></blockquote>
</blockquote>
<ul>
<li><strong>Preparing the Backup VM</strong></li>
</ul>
<blockquote>
<p>Here I use a virtual machine to illustrate the restore-to-a-different machine strategy. In practice though, this can also be a physical machine.</p>
<p>First, you will need to prepare a minimum VM that has the desired OS on it (in my case Ubuntu Server 7.04). The OS is needed because we are using TAR to do the backup and restore. It should be pretty easy though as most server version Linux images support unattended setup.</p>
<p>You do not need to install any security updates afterward as the system will be brought up to date during the restoration process.</p>
</blockquote>
<ul>
<li><strong>Resotring Backup Image to VM</strong></li>
</ul>
<blockquote>
<p>&nbsp;Now copy the backup image over to the VM. Because certain files can only be overwritten when they are not in use, we will perform the restoration in single user mode:</p>
<blockquote>
<p>init 1</p>
</blockquote>
<p>next we will restore the backup image:</p>
<blockquote>
<p>tar -xpzf /backup.tgz -C /</p>
</blockquote>
<p>DO NOT REBOOT AFTER RESTORE! If you reboot right after the restoration, the system will not be in a bootable state (e.g. system drive&#8217;s UUID has not been updated yet, if you reboot now you will not be able to boot into your system. In this case you will have to use a live CD to boot and fix your system from there).</p>
<p>First thing we need to do is to set the correct UUID for the partition we are booting from.</p>
<p>Do a <strong>df </strong>to see which partition is the root partition, e.g.</p>
<blockquote>
<p>Filesystem&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1K-blocks&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Used Available Use% Mounted on</p>
<p>/dev/sda1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 113892200&nbsp;&nbsp; 1007084 107099712&nbsp;&nbsp; 1% /
</p></blockquote>
<p>Find out the UUID of the partition:</p>
<blockquote>
<p>dumpe2fs /dev/sda1 | grep UUID</p>
</blockquote>
<p>Write down the UUID of the partition and double check to make sure that it is written down correctly as wrong UUID will lead to a boot failure.</p>
<p>Now, we need to edit <strong>/boot/grub/menu.lst </strong>to update the boot partition&#8217;s UUID.</p>
<p>In menu.lst, find entries like:</p>
<blockquote>
<p>title&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Ubuntu, kernel 2.6.20-16-server<br />
root&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (hd0,0)<br />
kernel&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /boot/vmlinuz-2.6.20-16-server root=UUID=401eeff8-c149-4db6-b4df-6cd899b880c6 ro quiet splash<br />
initrd&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /boot/initrd.img-2.6.20-16-server<br />
quiet<br />
savedefault</p>
</blockquote>
<p>And change the UUID to the one you just copied down. Again, use extra caution to ensure that the UUID is changed correctly.</p>
<p>Depending on the system, there might be quite a few entries with the same UUID as you might have different kernels installed. If you are not certain, change them all.</p>
<p>&nbsp;Now you should be able to reboot into the restored system. After reboot, you might not have access to the network any longer due to the MAC change of the ethernet during system restore. This can be fixed easily. Do a</p>
<blockquote>
<p>ipconfig -a</p>
</blockquote>
<p>you should see an entry with eth0 (or eth1). Copy down the HWaddr (e.g. 00:52:AA:C2:F9:CD) and use this value to update /etc/iftab</p>
<blockquote><p><strong>eth0</strong> mac 00:52:AA:C2:F9:CD arp 1
</p></blockquote>
<p>Make sure that the ether net interface is updated to eth0.</p>
<p>Now you should be able to use ifup eth0 to bring up the network. see <a href="http://communities.vmware.com/thread/46069">this thread</a> for more detailed discussion on this issue.</p>
</blockquote>
<p>One benefit of this backup strategy is that you are always guaranteed that the backup image works correctly, and you can have the backup system on standby using rsync to synchronize the backup machine and your production machine. And in the event of a disaster, your backup machine can kick in immediately.</p>
<p>Restoring the image back to the production machine is actually easier since you can just restore the image back without the need to change any configurations mentioned above (however, it is still a good idea to check).</p>
<blockquote>
<p>&nbsp;</p>
</blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.kerrywong.com/2007/10/05/a-physical-to-vm-backup-strategy-for-ubuntu-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
