<?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>KP Solutions &#187; backup</title>
	<atom:link href="http://www.kpsolution.com/blog/tag/backup/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.kpsolution.com/blog</link>
	<description>Solutions for Day to Day Technical Problems</description>
	<lastBuildDate>Tue, 24 Aug 2010 02:37:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
		<item>
		<title>Use RSYNC to backup data on a second hard disk</title>
		<link>http://www.kpsolution.com/blog/linux/use-rsync-to-backup-data-on-a-second-hard-disk/42/</link>
		<comments>http://www.kpsolution.com/blog/linux/use-rsync-to-backup-data-on-a-second-hard-disk/42/#comments</comments>
		<pubDate>Thu, 22 Jan 2009 02:33:52 +0000</pubDate>
		<dc:creator>Ketan Patel</dc:creator>
				<category><![CDATA[linux]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[rsync]]></category>

		<guid isPermaLink="false">http://www.kpsolution.com/blog/?p=42</guid>
		<description><![CDATA[On a production server, if you have two hard disk and do not want to spend extra $50 each month, then you could use rsync to backup the data from your main disk to the second disk. It&#8217;s very easy &#8230; <a href="http://www.kpsolution.com/blog/linux/use-rsync-to-backup-data-on-a-second-hard-disk/42/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>On a production server, if you have two hard disk and do not want to spend extra $50 each month, then you could use rsync to backup the data from your main disk to the second disk. It&#8217;s very easy to setup. All you to do is use to the following scripts. Save the following script as /disk3/rsync_backup.sh</p>
<blockquote><p>#!/bin/bash<br />
unset PATH</p>
<p># USER VARIABLES<br />
BACKUPDIR=/disk3                            # Folder on the backup server where the backups shall be located<br />
#KEY=/root/.ssh/id_rsa                        # SSH key<br />
#MYSQL_BACKUPSCRIPT=/root/my_backup.sh        # Path to the remote mysql backup script<br />
#PRODUCTION_USER=root@production.server.com    # The user and the address of the production server<br />
EXCLUDES=/disk1/backup_exclude                # File containing the excluded directories<br />
DAYS=60                                        # The number of days after which old backups will be deleted</p>
<p># PATH VARIABLES<br />
SH=/bin/sh                                    # Location of the bash bin in the production server!!!!</p>
<p>CP=/bin/cp;                                    # Location of the cp bin<br />
FIND=/usr/bin/find;                            # Location of the find bin<br />
ECHO=/bin/echo;                                # Location of the echo bin<br />
MK=/bin/mkdir;                                # Location of the mk bin<br />
SSH=/usr/bin/ssh;                            # Location of the ssh bin<br />
DATE=/bin/date;                                # Location of the date bin<br />
RM=/bin/rm;                                    # Location of the rm bin<br />
GREP=/bin/grep;                                # Location of the grep bin<br />
MYSQL=/usr/bin/mysql;                        # Location of the mysql bin<br />
MYSQLDUMP=/usr/bin/mysqldump;                # Location of the mysql_dump bin<br />
RSYNC=/usr/bin/rsync;                        # Location of the rsync bin<br />
TOUCH=/bin/touch;                            # Location of the touch bin</p>
<p>##                                                      ##<br />
##      &#8211;       DO NOT EDIT BELOW THIS HERE     &#8211;     ##<br />
##                                                      ##</p>
<p># CREATING NECESSARY FOLDERS<br />
$MK $BACKUPDIR<br />
CURRENT=$BACKUPDIR/current<br />
OLD=$BACKUPDIR/old<br />
$MK $CURRENT<br />
$MK $OLD<br />
# CREATING CURRENT DATE / TIME<br />
NOW=`$DATE &#8216;+%Y-%m&#8217;-%d_%H:%M`<br />
NOW=$OLD/$NOW<br />
$MK $NOW</p>
<p># CREATE REMOTE MYSQL BACKUP BY RUNNING THE REMOTE BACKUP SCRIPT<br />
# $SSH -i $KEY $PRODUCTION_USER &#8220;$SH $MYSQL_BACKUPSCRIPT&#8221;</p>
<p># RUN RSYNC INTO CURRENT<br />
#$RSYNC                                                            \<br />
#    -apvz &#8211;delete &#8211;delete-excluded                        \<br />
#     &#8211;exclude-from=&#8221;$EXCLUDES&#8221;                                \<br />
#      -e &#8220;$SSH -i $KEY&#8221;                                        \<br />
#       $PRODUCTION_USER:/                                        \<br />
#        $CURRENT ;</p>
<p>// No Compression<br />
$RSYNC                                                            \<br />
-apv &#8211;delete &#8211;delete-excluded                        \<br />
&#8211;exclude-from=&#8221;$EXCLUDES&#8221;                                \<br />
/                                \<br />
$CURRENT ;</p>
<p># UPDATE THE MTIME TO REFELCT THE SNAPSHOT TIME<br />
$TOUCH $BACKUPDIR/current</p>
<p># MAKE HARDLINK COPY<br />
$CP -al $CURRENT/* $NOW</p>
<p># REMOVE OLD BACKUPS<br />
for FILE in &#8220;$( $FIND $OLD -maxdepth 1 -type d -mtime +$DAYS )&#8221;<br />
do<br />
#    $RM -Rf $FILE<br />
$ECHO $FILE<br />
done<br />
exit 0</p></blockquote>
<p>Save the following to /disk3/backup_exclude. Essentially, these are the files/folders you do not wish to backup using rsync.</p>
<blockquote><p>/disk3/<br />
/bin/<br />
/boot/<br />
/dev/<br />
/lib/<br />
/lost+found/<br />
/mnt/<br />
/opt/<br />
/proc/<br />
/sbin/<br />
/sys/<br />
/tmp/<br />
/usr/<br />
/var/log/<br />
/var/spool/<br />
/var/lib/php4/<br />
/var/lib/mysql/</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://www.kpsolution.com/blog/linux/use-rsync-to-backup-data-on-a-second-hard-disk/42/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
