<?xml version="1.0" encoding="UTF-8"?>
<essay xml:lang="en" version="5.0" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:gal="http://norman.walsh.name/rdf/gallery#" xmlns:foaf="http://xmlns.com/foaf/0.1/">
<info>
    
    
    
    
    
    
    
    
    
    
    
    
    
    
<title>backuporama</title><biblioid class="uri">http://norman.walsh.name/2006/03/27/backuporama</biblioid>
<volumenum>9</volumenum>
<issuenum>35</issuenum>
<pubdate>2006-03-27T15:24:39-05:00</pubdate>
<date>$Date: 2006-03-27 16:37:25 -0500 (Mon, 27 Mar 2006) $</date>
<author>
      <personname>
<firstname>Norman</firstname>
	<surname>Walsh</surname>
</personname>
    </author>
<copyright>
      <year>2006</year>
      <holder>Norman Walsh</holder>
    </copyright>
<abstract>
<para>Sean asks “what's your backup strategy?”</para>
</abstract>
<dc:subject rdf:resource="http://norman.walsh.name/knows/taxonomy#Gadgets"/>
<dc:subject rdf:resource="http://norman.walsh.name/knows/taxonomy#Linux"/>
<dc:subject rdf:resource="http://norman.walsh.name/knows/taxonomy#Software"/>
<dc:subject rdf:resource="http://norman.walsh.name/knows/taxonomy#Windows"/>
</info>

<para xml:id="p1">Since I've been meaning to write this since
<link xlink:href="/2006/02/23/backup">my last post</link> on backups, I'll
do my part to 
<link xlink:href="http://seanmcgrath.blogspot.com/archives/2006_03_26_seanmcgrath_archive.html#114344964752307289">spread
the meme</link>.</para>

<para xml:id="p2">Like <personname>
<firstname>Sean</firstname>
<surname role="suppress">McGrath</surname>
    </personname>,
I run
<link xlink:href="http://en.wikipedia.org/wiki/Ubuntu_Linux">Ubuntu</link>
on my
<link xlink:href="http://en.wikipedia.org/wiki/Thinkpad">T42p</link>.
And like Sean,
I keep as much stuff as I possibly can checked into
source code control systems at work, on
<link xlink:href="http://www.java.net/">Java.net</link>, on
<link xlink:href="http://sourceforge.net/">Sourceforge</link>, etc. 
If I'm writing code or prose, I want it checked in somewhere. I run a
<link xlink:href="http://en.wikipedia.org/wiki/Subversion_%28software%29">Subversion</link>
repository on my laptop so even private stuff is “checked in”.
(A local repository doesn't save me from a disk disaster, but the real
risk on a day-to-day basis isn't hardware failure, it's human stupidity.
Mine.)</para>

<para xml:id="p3">On a roughly monthly basis, I connect an external drive and run
the following script:</para>

<programlisting>#!/bin/bash

BROOT=/media/usbdisk/Backup/ndw
DATE=`date "+%Y-%m-%d"`

if [ ! -d $BROOT ]; then
    echo "No backup directory: $BROOT"
    exit 1;
fi

echo "Stop mysql and hit return..."
read $x

echo "Backing up /var/lib/mysql/"
rsync -a --delete /var/lib/mysql/ $BROOT/var/lib/mysql/

echo "Ok, you can start mysql again..."

echo "Backing up /etc/"
rsync -a --delete /etc/ $BROOT/etc/

echo "Backing up /opt/"
rsync -a --delete /opt/ $BROOT/opt/

echo "Backing up /home/"
rsync -a --delete \
      --exclude ndw/Mail/ \
      --exclude home/ndw/Desktop/ \
      --exclude home/ndw/.Trash/ \
      --exclude home/ndw/.mozilla/firefox/926iwrha.default/Cache/ \
      --exclude home/ndw/.mozilla/firefox/oijtdfv2.xproc/Cache/ \
      --exclude home/ndw/tmp/ \
      --exclude home/ndw/scratch/ \
      --exclude home/ndw/.thumbnails/ \
      /home/ $BROOT/home/

echo "(Mail will be done later...)"

echo "Backing up /share/"
rsync -a --delete /share/ $BROOT/share/

echo "Backing up /root/"
rsync -a --delete /root/ $BROOT/root/

echo "Backing up /usr/local/"
rsync -a --delete /usr/local/ $BROOT/usr/local/

echo "Backing up /home/ndw/Mail/"
cd /home/ndw
tar cf - .news* .gnus* Mail | gzip &gt; ${BROOT}-mail.$DATE.tar.gz

echo "Compressing backup..."
cd $BROOT
cd ..
tar cf - ndw | gzip &gt; ndw.$DATE.tar.gz

echo "Done"</programlisting>

<para xml:id="p4">The <link xlink:href="http://en.wikipedia.org/wiki/MySQL">MySQL</link>
backup captures my
<link xlink:href="http://en.wikipedia.org/wiki/DSPAM">DSPAM</link>
training database. I ask first because I have to stop my
periodic mail collection script so that it doesn't run while MySQL is down.
(I suppose I could fix that, but it hasn't been a big deal.)</para>

<para xml:id="p5">I backup <filename>/etc</filename>, <filename>/opt</filename>,
<filename>/home</filename>, <filename>/share</filename> (where I keep
most things that aren't in my home directory), <filename>/root</filename>,
and <filename>/usr/local</filename>. Mail is backed up in a slightly
different way because
it consists of so many tiny little files.</para>

<para xml:id="p6">I keep photographs and music under <filename>/share</filename>,
so that gets backed up with everything else. But I also copy those files
separately onto backups of their own.</para>

<para xml:id="p7">Using
<link xlink:href="http://en.wikipedia.org/wiki/Rsync">rsync</link><footnote>
<para xml:id="p8">The value of rsync with a local disk may be negligible, but a slightly
modified version of this script used to run backups across my network before
I had a USB2 enclosure.</para>
    </footnote>
means that I don't copy over a bunch of stuff
that hasn't changed (like huge parts of <filename>/share</filename> and
<filename>/usr/local</filename>). But it also means that I only have
one backup. That's why I added the last steps, to make a dated, compressed
archive. Being able to look a little further back in time has saved my
butt more than once.</para>

<para xml:id="p9">I don't use
<link xlink:href="http://en.wikipedia.org/wiki/Microsoft_Windows">Windows</link>,
but <personname>
      <firstname>Deb</firstname>
<surname role="suppress">Walsh</surname>
    </personname> does. I backup
her laptop by
<link xlink:href="http://en.wikipedia.org/wiki/Smbmount">smbmount</link>ing
it and copying the relevant bits onto my laptop, where it gets backed up
as per above.</para>

</essay>

