<?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>Kevin Deldycke &#187; Backup</title> <atom:link href="http://kevin.deldycke.com/tag/backup/feed/" rel="self" type="application/rss+xml" /><link>http://kevin.deldycke.com</link> <description>Free software engineer &#38; wannabe videomaker</description> <lastBuildDate>Fri, 03 Feb 2012 19:08:27 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>Cloud-based Server Backups with Duplicity and Amazon S3</title><link>http://kevin.deldycke.com/2011/09/cloud-based-server-backups-duplicity-amazon-s3/</link> <comments>http://kevin.deldycke.com/2011/09/cloud-based-server-backups-duplicity-amazon-s3/#comments</comments> <pubDate>Tue, 13 Sep 2011 10:35:33 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[amason s3]]></category> <category><![CDATA[amazon AWS]]></category> <category><![CDATA[Backup]]></category> <category><![CDATA[cloud-computing]]></category> <category><![CDATA[cron]]></category> <category><![CDATA[Debian]]></category> <category><![CDATA[duplicity]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[shell]]></category> <category><![CDATA[squeeze]]></category> <category><![CDATA[storage]]></category><guid isPermaLink="false">http://kevin.deldycke.com/?p=3557</guid> <description><![CDATA[For years I was backing up my server with website-backup.py, a custom script I wrote to manage data mirroring, do incremental backups and monthly snapshots based on rdiff-backup, rsync, tar and bzip2. All these data were pushed to a storage &#8230; <a href="http://kevin.deldycke.com/2011/09/cloud-based-server-backups-duplicity-amazon-s3/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>For years I was backing up my server with <code><a href="http://github.com/kdeldycke/scripts/blob/master/website-backup.py">website-backup.py</a></code>, a custom script I wrote to manage data mirroring, do incremental backups and monthly snapshots based on <code><a href="http://www.nongnu.org/rdiff-backup/">rdiff-backup</a></code>, <code>rsync</code>, <code>tar</code> and <code>bzip2</code>. All these data were pushed to a storage server hosted at home.</p><p>I&#8217;ve just replaced my script with <a href="http://duplicity.nongnu.org">duplicity</a>, a tool written by the same author of <code>rdiff-backup</code>. And <a href="http://aws.amazon.com/s3/">Amazon S3 cloud storage</a> replaced my home server. Here is how I did it.</p><p>First, we need to create an account on <a href="http://aws.amazon.com">Amazon AWS</a>. This is easy and fast. My account was activated in minutes.</p><p>Now that you have access to Amazon&#8217;s cloud, let&#8217;s create a bucket on S3. I used the reversed domain name of the server, which give me a bucket name like <code>com.example.server.backup</code>. With this naming scheme, I can identify the purpose of the bucket by its label only.</p><p>Duplicity can use the <a href="http://aws.amazon.com/about-aws/whats-new/2010/05/19/announcing-amazon-s3-reduced-redundancy-storage/">cheaper RRS storage</a>, but you need at least version 0.6.09. Having a Debian Squeeze, the only way to get a recent version is to install it from the backports:</p><pre class="brush: bash; title: ; notranslate">
$ apt-get -t squeeze-backports install duplicity python-boto
</pre><p>Then I created a simple symmetric key with GPG:</p><pre class="brush: bash; title: ; notranslate">
$ gpg --gen-key
</pre><p>You absolutely need to provide a passphrase, else Duplicity will refuse to run.</p><p>Now update the script below with the GPG key passphrase and your AWS credentials:</p><pre class="brush: bash; title: ; notranslate">
# Do not let this script run more than once
[ `ps axu | grep -v &quot;grep&quot; | grep --count &quot;duplicity&quot;` -gt 0 ] &amp;&amp; exit 1

# Set some environment variables required by duplicity
export PASSPHRASE=XXXXXXXXXX
export AWS_ACCESS_KEY_ID=XXXXXXXXXX
export AWS_SECRET_ACCESS_KEY=XXXXXXXXXX

# ~/.cache/duplicity/ should be excluded, as explained in http://comments.gmane.org/gmane.comp.sysutils.backup.duplicity.general/4449
PARAMS='--exclude-device-files --exclude-other-filesystems --exclude **/.cache/** --exclude **/.thumbnails/** --exclude /mnt/ --exclude /tmp/ --exclude /dev/ --exclude /sys/ --exclude /proc/ --exclude /media/ --exclude /var/run/ --volsize 10 --s3-use-rrs --asynchronous-upload -vinfo'
DEST='s3+http://com.example.server.backup'

# Export MySQL databases
mysqldump --user=root --opt --all-databases &gt; /home/kevin/mysql-backup.sql

# Do the backup
duplicity $PARAMS --full-if-older-than 1M / $DEST

# Clean things up
duplicity remove-older-than 1Y --force --extra-clean $PARAMS $DEST

# Remove temporary environment variables
unset PASSPHRASE
unset AWS_ACCESS_KEY_ID
unset AWS_SECRET_ACCESS_KEY
</pre><p>Before running duplicity, the script will dump all MySQL databases to a plain-text file. Then the first duplicity call will do the backup itself, and the second call will remove all backup older than a year.</p><p>I saved the script above in <code>/home/kevin/s3-backup.sh</code> and <code>cron</code>-ed it:</p><pre class="brush: bash; title: ; notranslate">
$ chmod 755 /home/kevin/s3-backup.sh
$ echo &quot;
# Backup everything to an Amazon S3 storage
0 1 * * * root /home/kevin/s3-backup.sh
&quot; &gt; /etc/cron.d/s3-backup
</pre><p>I can now sleep better knowing all the work I do on my server will not be lost in case of a catastrophic event. Amazon S3 is today a no-brainer for server backups: your data will be secured and available. And for small quantity of data (like the 10 Go of my server), it&#8217;s incredibly cheap. Especially if you compare it to the cost of maintaining a storage server at home.</p><p>This solution is so good and obvious, that I don&#8217;t know why I haven&#8217;t implemented it earlier&#8230; <img src='http://kevin.deldycke.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2011/09/cloud-based-server-backups-duplicity-amazon-s3/feed/</wfw:commentRss> <slash:comments>7</slash:comments> </item> <item><title>How-to extract data trapped into an iPhone</title><link>http://kevin.deldycke.com/2010/09/how-to-extract-data-trapped-iphone/</link> <comments>http://kevin.deldycke.com/2010/09/how-to-extract-data-trapped-iphone/#comments</comments> <pubDate>Thu, 16 Sep 2010 19:24:45 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[Android]]></category> <category><![CDATA[Apple]]></category> <category><![CDATA[Backup]]></category> <category><![CDATA[csv]]></category> <category><![CDATA[iphone]]></category> <category><![CDATA[ITunes]]></category> <category><![CDATA[OSX]]></category> <category><![CDATA[Smartphones]]></category> <category><![CDATA[sqlite]]></category><guid isPermaLink="false">http://kevin.deldycke.com/?p=1913</guid> <description><![CDATA[After 2 years using an iPhone 3G, it&#8217;s time for me to switch to the Android world. My Apple era is over, I need a plateform that is more linux and open-source friendly. Before erasing and selling my iPhone, I &#8230; <a href="http://kevin.deldycke.com/2010/09/how-to-extract-data-trapped-iphone/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>After 2 years using an <a href="http://www.amazon.com/gp/product/B001AXA056/ref=as_li_tf_tl?ie=UTF8&#038;tag=kevideld-20&#038;linkCode=as2&#038;camp=217145&#038;creative=399373&#038;creativeASIN=B001AXA056">iPhone 3G</a>, it&#8217;s time for me to <a href="http://twitter.com/kdeldycke/status/24219289221">switch to the Android world</a>. <a href="http://twitter.com/kdeldycke/status/22007247873">My Apple era is over</a>, I need a plateform that is more linux and open-source friendly.<img src="http://www.assoc-amazon.com/e/ir?t=kevideld-20&#038;l=as2&#038;o=1&#038;a=B001AXA056&#038;camp=217145&#038;creative=399373" width="1" height="1" border="0" alt="" style="border:none !important; margin:0px !important;" /></p><p>Before erasing and <a href="http://twitter.com/kdeldycke/status/24687160120">selling my iPhone</a>, I want to backup and extract all the data I produced with it and that is still trapped inside. This mean photos, SMSs, voice messages, safari bookmarks, etc&#8230;</p><p>There is a nice OSX app simply called <a href="http://supercrazyawesome.com">iPhone Backup Extractor</a> which let you get these data. Instead of getting data directly from the iPhone, it reads its backups made by iTunes.</p><p>So first thing you have to do is to backup your phone using iTunes:<br /> <a href="http://kevin.deldycke.com/wp-content/uploads/2010/09/iphone-itunes-sync.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2010/09/iphone-itunes-sync-300x213.png" alt="" title="iphone-itunes-sync" width="300" height="213" class="aligncenter size-medium wp-image-1945" /></a></p><p>Then you can download and run the iPhone Backup Extractor app:<br /> <a href="http://kevin.deldycke.com/wp-content/uploads/2010/09/iphone-backup-extrator.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2010/09/iphone-backup-extrator-300x220.png" alt="" title="iphone-backup-extrator" width="300" height="220" class="aligncenter size-medium wp-image-1947" /></a></p><p>Here you just have to click the <em>Read Backups</em> button to get a list of all backups available on your machine. Then choose your latest backup:<br /> <a href="http://kevin.deldycke.com/wp-content/uploads/2010/09/list-of-iphone-backups.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2010/09/list-of-iphone-backups-300x224.png" alt="" title="list-of-iphone-backups" width="300" height="224" class="aligncenter size-medium wp-image-1948" /></a></p><p>You&#8217;ll get a list of all installed applications on your iPhone. As we are interested in &#8220;core&#8221; iPhone apps (SMSs, photos and so on), we&#8217;ll choose the &#8220;iOS Files&#8221; item, then choose a place where to extract:<br /> <a href="http://kevin.deldycke.com/wp-content/uploads/2010/09/iphone-backup-content.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2010/09/iphone-backup-content-300x300.png" alt="" title="iphone-backup-content" width="300" height="300" class="aligncenter size-medium wp-image-1950" /></a><br /> <a href="http://kevin.deldycke.com/wp-content/uploads/2010/09/iphone-backup-extraction-destination.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2010/09/iphone-backup-extraction-destination-300x213.png" alt="" title="iphone-backup-extraction-destination" width="300" height="213" class="aligncenter size-medium wp-image-1951" /></a></p><p>Then the extraction itself will take place:<br /> <a href="http://kevin.deldycke.com/wp-content/uploads/2010/09/iphone-backup-extraction.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2010/09/iphone-backup-extraction-300x78.png" alt="" title="iphone-backup-extraction" width="300" height="78" class="aligncenter size-medium wp-image-1953" /></a></p><p>You&#8217;ve just finished the essential part of the process. You now have a nice folder structure containing all the important informations that was trapped in your phone:<br /> <a href="http://kevin.deldycke.com/wp-content/uploads/2010/09/iphone-backup-extraction-content.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2010/09/iphone-backup-extraction-content-300x182.png" alt="" title="iphone-backup-extraction-content" width="300" height="182" class="aligncenter size-medium wp-image-1955" /></a></p><p>Let&#8217;s browse the file structure that was just created. You can see photos are available as is, in the <code>/iOS Files/Media/DCIM/XXXAPPLE/</code>:<br /> <a href="http://kevin.deldycke.com/wp-content/uploads/2010/09/iphone-photo-location.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2010/09/iphone-photo-location-300x111.png" alt="" title="iphone-photo-location" width="300" height="111" class="aligncenter size-medium wp-image-1958" /></a></p><p>Most of other datas are located in the <code>/iOS Files/Library/</code> folder. For example here are voice messages:<br /> <a href="http://kevin.deldycke.com/wp-content/uploads/2010/09/iphone-voicemessages-location.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2010/09/iphone-voicemessages-location-300x127.png" alt="" title="iphone-voicemessages-location" width="300" height="127" class="aligncenter size-medium wp-image-1960" /></a></p><p>Again, <code>.amr</code> files here are playable as-is, like <a href="http://www.videolan.org/vlc/">VLC</a> or <a href="http://www.mplayerhq.hu">mplayer</a>.</p><p>And finaly most, if not all, other kind of data and metadata are stored in SQLite databases (<code>.db</code> files). The best GUI I found to manipulate with these files under Mac OSX is <a href="http://sourceforge.net/projects/sqlitebrowser/">SQLite Database Browser</a>. See how I can easily extract to a CSV file all metadatas associated with my voice messages:<br /> <a href="http://kevin.deldycke.com/wp-content/uploads/2010/09/sqlite-database-browser-opening.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2010/09/sqlite-database-browser-opening-300x199.png" alt="" title="sqlite-database-browser-opening" width="300" height="199" class="aligncenter size-medium wp-image-1970" /></a><br /> <a href="http://kevin.deldycke.com/wp-content/uploads/2010/09/iphone-voicemail-database-tables.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2010/09/iphone-voicemail-database-tables-300x202.png" alt="" title="iphone-voicemail-database-tables" width="300" height="202" class="aligncenter size-medium wp-image-1971" /></a><br /> <a href="http://kevin.deldycke.com/wp-content/uploads/2010/09/iphone-voicemail-table-content.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2010/09/iphone-voicemail-table-content-300x202.png" alt="" title="iphone-voicemail-table-content" width="300" height="202" class="aligncenter size-medium wp-image-1974" /></a><br /> <a href="http://kevin.deldycke.com/wp-content/uploads/2010/09/sqlite-csv-table-export.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2010/09/sqlite-csv-table-export-300x129.png" alt="" title="sqlite-csv-table-export" width="300" height="129" class="aligncenter size-medium wp-image-1975" /></a></p> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2010/09/how-to-extract-data-trapped-iphone/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>How-to export/backup Lotus Notes mails</title><link>http://kevin.deldycke.com/2010/06/how-to-export-backup-lotus-notes-mails/</link> <comments>http://kevin.deldycke.com/2010/06/how-to-export-backup-lotus-notes-mails/#comments</comments> <pubDate>Fri, 25 Jun 2010 09:30:11 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[Backup]]></category> <category><![CDATA[Databases]]></category> <category><![CDATA[E-mail]]></category> <category><![CDATA[export]]></category> <category><![CDATA[IBM Lotus Notes]]></category> <category><![CDATA[windows]]></category><guid isPermaLink="false">http://kevin.deldycke.com/?p=1574</guid> <description><![CDATA[You are using Lotus Notes as your mail platform. Unfortunately your mailbox has a quota you&#8217;ve already reached and you need space. A solution consist in exporting regularly your mails on your local machine to free up your inbox. Here &#8230; <a href="http://kevin.deldycke.com/2010/06/how-to-export-backup-lotus-notes-mails/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>You are using Lotus Notes as your mail platform. Unfortunately your mailbox has a quota you&#8217;ve already reached and you need space. A solution consist in exporting regularly your mails on your local machine to free up your inbox. Here is a little article documenting the export procedure using the fat desktop client.</p><p>If screenshots were taken with a french version, instructions given here are for the english one. This will give you enough clues to perform the export whatever the localisation is. The Lotus Notes version I used was the 7.0.2 release.</p><p>So first, let&#8217;s start Notes and open your mailbox. You should be on a screen similar to this one:<br /> <a href="http://kevin.deldycke.com/wp-content/uploads/2010/06/lotus-notes-mail-main-screen.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2010/06/lotus-notes-mail-main-screen-300x217.png" alt="" title="lotus-notes-mail-main-screen" width="300" height="217" class="aligncenter size-medium wp-image-1577" /></a></p><p>Then, go to the <code>File</code> › <code>Database</code> › <code>New Copy</code> menu:<br /> <a href="http://kevin.deldycke.com/wp-content/uploads/2010/06/lotus-notes-database-export-menu.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2010/06/lotus-notes-database-export-menu-300x217.png" alt="" title="lotus-notes-database-export-menu" width="300" height="217" class="aligncenter size-medium wp-image-1578" /></a></p><p>And you&#8217;ll get an export screen that&#8217;ll let you choose where to create a local copy of your database:<br /> <a href="http://kevin.deldycke.com/wp-content/uploads/2010/06/export-screen.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2010/06/export-screen-300x199.png" alt="" title="export-screen" width="300" height="199" class="aligncenter size-medium wp-image-1579" /></a><br /> This will generate a <code>.nsf</code> file containing all your current mail.</p><p>Now that you have a backup, you are free to delete all your mails in Lotus Notes. By following this procedure regulary, you can create yearly or monthly archives of you mails without reaching the mailbox quota ! For example, this is how my local archive folder looks like:<br /> <a href="http://kevin.deldycke.com/wp-content/uploads/2010/06/lotus-notes-exported-mail-archives.png"><img src="http://kevin.deldycke.com/wp-content/uploads/2010/06/lotus-notes-exported-mail-archives.png" alt="" title="lotus-notes-exported-mail-archives" width="150" height="138" class="aligncenter size-full wp-image-1580" /></a></p> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2010/06/how-to-export-backup-lotus-notes-mails/feed/</wfw:commentRss> <slash:comments>4</slash:comments> </item> <item><title>Auto-saving a file at regular intervals</title><link>http://kevin.deldycke.com/2009/12/auto-saving-file-regular-intervals/</link> <comments>http://kevin.deldycke.com/2009/12/auto-saving-file-regular-intervals/#comments</comments> <pubDate>Wed, 02 Dec 2009 20:37:09 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[Backup]]></category> <category><![CDATA[cron]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[save]]></category><guid isPermaLink="false">http://kevin.deldycke.com/?p=911</guid> <description><![CDATA[Here is a way to autosave a file at regular intervals: use cron ! The trick is to know that cron need percents to be escaped by a backslash in the command zone. For example, here is my crontab entry &#8230; <a href="http://kevin.deldycke.com/2009/12/auto-saving-file-regular-intervals/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p><a href="http://kevin.deldycke.com/wp-content/uploads/2009/12/editing-cron-with-vi.jpg"><img src="http://kevin.deldycke.com/wp-content/uploads/2009/12/editing-cron-with-vi-150x150.jpg" alt="editing-cron-with-vi" title="editing-cron-with-vi" width="150" height="150" class="alignleft size-thumbnail wp-image-918" /></a> Here is a way to autosave a file at regular intervals: use <code>cron</code> !</p><p>The trick is to know that <code>cron</code> need percents to be escaped by a backslash in the command zone. For example, here is my crontab entry to create every 10 minutes a local backup of an important project file I currently work on:</p><div style="clear: both"></div><pre class="brush: bash; title: ; notranslate">
*/10 * * * * kevin cp &quot;/home/kevin/Desktop/Projects/Very Important Project/project.file&quot; &quot;/home/kevin/Desktop/Projects/Very Important Project/project.file-backup-`date +\%s`&quot;
</pre><p>Quick and dirty, but may saves you precious time on <a href="http://twitter.com/kdeldycke/status/6158072244">unstable machines</a> ! <img src='http://kevin.deldycke.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2009/12/auto-saving-file-regular-intervals/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Heroic journey to RAID-5 data recovery</title><link>http://kevin.deldycke.com/2008/07/heroic-journey-to-raid-5-data-recovery/</link> <comments>http://kevin.deldycke.com/2008/07/heroic-journey-to-raid-5-data-recovery/#comments</comments> <pubDate>Thu, 24 Jul 2008 21:20:27 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[array]]></category> <category><![CDATA[Backup]]></category> <category><![CDATA[disk]]></category> <category><![CDATA[drive]]></category> <category><![CDATA[Hardware]]></category> <category><![CDATA[HDD]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[mdadm]]></category> <category><![CDATA[monitoring]]></category> <category><![CDATA[RAID]]></category> <category><![CDATA[Server]]></category> <category><![CDATA[system]]></category> <category><![CDATA[UPS]]></category><guid isPermaLink="false">http://kevin.deldycke.com/?p=246</guid> <description><![CDATA[Last week there was a power grid failure which break down my server&#8217;s RAID array. I have no UPS (as I&#8217;m a skinflint) and no automatic email alerts (because I&#8217;m too lazy to set it up). As a result, for &#8230; <a href="http://kevin.deldycke.com/2008/07/heroic-journey-to-raid-5-data-recovery/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Last week there was a power grid failure which break down my server&#8217;s RAID array. I have no <a href="http://en.wikipedia.org/wiki/Uninterruptible_power_supply">UPS</a> (as I&#8217;m a skinflint) and no automatic email alerts (because I&#8217;m too lazy to set it up). As a result, for 5 days, my 3-disk <a href="http://en.wikipedia.org/wiki/RAID_5">RAID-5 array</a> was relying on only 2 disks until I noticed the issue&#8230;</p><p>By using a combination of following commands, I was soon aware of the gravity of the situation:</p><pre class="brush: bash; title: ; notranslate">
cat /proc/mdstat
mdadm --examine /dev/sda1
</pre><p>My <code>/dev/sda1</code> disk was kicked out of the array, so I did the right stuff which consisted of reconstructing the array:</p><pre class="brush: bash; title: ; notranslate">
mdadm /dev/md0 -a /dev/sda1
</pre><p>Then, in an unlucky combination of cosmic ray bombardment, spooky action at a distance and astrological misalignment, half-way to the end of the rebuilding process (which can take up to 5 hours), another disk failed ! It was late, I was tired and utterly worried about losing 1.5 To of precious data. In such a bad shape, I was afraid to worsen the situation. So I decided to shutdown the server and sleep on the problem.</p><p>The next day I tried to boot my server to find it (surprise !) stuck in the middle of the boot process, with the famous message:</p><pre class="brush: bash; title: ; notranslate">
hit control-D to continue or give root password to fix manually
</pre><p>This is &#8220;normal&#8221; as my server tried to mount the <a href="http://en.wikipedia.org/wiki/Ext3">ext3 filesystem</a> from the <code>/dev/md0</code> partition that was just assembled by <code>mdadm</code>. Of course <code>md0</code>, if assembled and available to the system, was not running because only one disk, out of three, was in a clean state.</p><p>I skip here the epic substory in which I wasted days in a search of a working keyboard, but I let you imagine how such adventures makes my week&#8230;</p><p>Eventually, I was able to analyze the situation in details. My first reflex ? Check that disks are not physically dead:</p><pre class="brush: bash; title: ; notranslate">
fdisk -l /dev/sda
fdisk -l /dev/sdb
fdisk -l /dev/sdc
</pre><p>&#8220;Linux raid partitions&#8221; (type code &#8220;<code>fd</code>&#8220;) are still there. Good. I assumed here that disks where not physically damaged. Maybe I should have looked at <a href="http://en.wikipedia.org/wiki/Self-Monitoring,_Analysis,_and_Reporting_Technology">S.M.A.R.T.</a> datas and statistics (via <a href="http://smartmontools.sourceforge.net">smartmontools</a>). But remember, I&#8217;m lazy (and a bit crazy).</p><p>The next step was to get informations about the RAID array itself using:</p><pre class="brush: bash; title: ; notranslate">
mdadm --detail /dev/md0
</pre><p>which output the status table below (probably inaccurate as I reconstructed it afterwards):</p><pre class="brush: bash; title: ; notranslate">
Number   Major   Minor   RaidDevice State
   0       0        0        0      removed
   1       0        0        1      faulty removed
   2       8       33        2      active sync   /dev/sdc1
   3       8       17        3      spare
</pre><p>What this table told us ?</p><ul><li>The array is up, but not running. One of its device (<code>sdc1</code>) was clean and active, but it&#8217;s not enough to get a working RAID-5.</li><li>My first attempt to rebuild the array lead to an unexpected result: it added <code>sda1</code> as a spare device (in slot #3).</li><li>It confirm that <code>sdb1</code> unexpectedly failed and is now in a bad state (&#8220;<code>faulty removed</code>&#8220;).</li></ul><p>Then I stopped the array and tried to fearlessly (re)assemble it using 3 differents methods:</p><pre class="brush: bash; title: ; notranslate">
mdadm -S /dev/md0
mdadm -A /dev/md0
mdadm --assemble /dev/md0 --verbose /dev/sd[abc]1
mdadm --assemble --force --scan /dev/md0 --verbose
</pre><p>It always failed with messages like:</p><pre class="brush: bash; title: ; notranslate">
mdadm: failed to RUN_ARRAY /dev/md0: Input/output error
mdadm: /dev/md0 assembled from 1 drives and 1 spare - not enough to start the array.
</pre><p>So I examined each drive from <code>mdadm</code>&#8216;s point of view:</p><pre class="brush: bash; title: ; notranslate">
mdadm -E /dev/sda1
mdadm -E /dev/sdb1
mdadm -E /dev/sdc1
mdadm -E /dev/sd[abc]1 | grep Event
</pre><p>The lastest command compare the &#8220;<code>Event</code>&#8221; attribute of all devices. It output something like:</p><pre class="brush: bash; title: ; notranslate">
Events : 0.53120
Events : 0.53108
Events : 0.53120
</pre><p>which indicate that <code>sda1</code> and <code>sdc1</code> are somewhat synced (share the same number) and <code>sdb1</code> &#8220;late&#8221; (lower number).</p><p>Here I&#8217;ve got the idea of recreating the raid array without <code>sdb1</code>, relying only on <code>sda1</code> and <code>sdc1</code>, by using the &#8220;magic&#8221; (hence dangerous) <code>--assume-clean</code> option. The latter doesn&#8217;t build, erase or initialize a new array. It just try to assemble it &#8220;as is&#8221;. Here is the command:</p><pre class="brush: bash; title: ; notranslate">
mdadm --create /dev/md0 --assume-clean --level=5 --verbose --raid-devices=3 /dev/sda1 missing /dev/sdc1
</pre><p>And it worked ! <img src='http://kevin.deldycke.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /></p><p>I mounted the <code>md0</code> partition and cleaned it up:</p><pre class="brush: bash; title: ; notranslate">
fsck.ext3 -v /dev/md0
mount /dev/md0
</pre><p>I updated my <a href="http://neil.brown.name/blog/mdadm">mdadm</a> configuration before rebooting my server:</p><pre class="brush: bash; title: ; notranslate">
mdadm --detail --scan &gt;&gt; /etc/mdadm/mdadm.conf
vi /etc/mdadm/mdadm.conf
reboot
</pre><p>But history repeat itself, and again, the system hang up during boot. Except this time I knew what was happening: the boot process detected the remaining <code>sdb1</code> device as part of the old array (the one before the regeneration I did above) and tried to run it. <a href="http://kevin.deldycke.com/2007/03/how-to-recover-a-raid-array-after-having-zero-ized-superblocks/">Remembering my last year post</a>, I zero-ized the superblock of <code>sdb1</code>:</p><pre class="brush: bash; title: ; notranslate">
mdadm -S /dev/md0
mdadm --zero-superblock /dev/sdb1
</pre><p>A server reboot proved I was right and my <code>md0</code> partition was automagically mounted in altered state:</p><pre class="brush: bash; title: ; notranslate">
localhost:~# cat /proc/mdstat
Personalities : [raid6] [raid5] [raid4]
md0 : active raid5 sdb1[3] sda1[0] sdc1[2]
      1465143808 blocks level 5, 64k chunk, algorithm 2 [3/2] [U_U]

unused devices: &lt;none&gt;
</pre><p>I just had to re-add <code>sdb1</code> to fill the available slot and update the mdadm configuration to get back my array in its initial state:</p><pre class="brush: bash; title: ; notranslate">
mdadm --manage /dev/md0 --add /dev/sdb1
mdadm --detail --scan &gt;&gt; /etc/mdadm/mdadm.conf
vi /etc/mdadm/mdadm.conf
</pre>]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2008/07/heroic-journey-to-raid-5-data-recovery/feed/</wfw:commentRss> <slash:comments>10</slash:comments> </item> <item><title>Website Backup Script: bug fix release</title><link>http://kevin.deldycke.com/2008/05/website-backup-script-bug-fix-release/</link> <comments>http://kevin.deldycke.com/2008/05/website-backup-script-bug-fix-release/#comments</comments> <pubDate>Sun, 25 May 2008 23:38:44 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[Backup]]></category> <category><![CDATA[CLI]]></category> <category><![CDATA[FTP]]></category> <category><![CDATA[lftp]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[MySQL]]></category> <category><![CDATA[mysqldump]]></category> <category><![CDATA[Network]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[rdiff-backup]]></category> <category><![CDATA[rsync]]></category> <category><![CDATA[Script]]></category> <category><![CDATA[Server]]></category> <category><![CDATA[SSH]]></category> <category><![CDATA[Web]]></category><guid isPermaLink="false">http://kevin.deldycke.com/?p=222</guid> <description><![CDATA[14 months after the last release, here is a new version of my website backup script. As you can see in the changelog, this version is essentially released to fix some bugs. Changelog: Check version of Python (at least v2.4 &#8230; <a href="http://kevin.deldycke.com/2008/05/website-backup-script-bug-fix-release/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p><a href="http://kevin.deldycke.com/2007/03/website-backup-script-mysql-dumps-and-ssh-supported/">14 months after the last release</a>, here is a <a href="http://kevin.deldycke.com/static/scripts/website-backup-2008_05_25.py">new version of my website backup script</a>. As you can see in the changelog, this version is essentially released to fix some bugs.</p><p>Changelog:</p><ul><li>Check version of Python (at least v2.4 is required)</li><li>Rename <code>--debug</code> option to <code>--verbose</code></li><li>Add a <code>--dry-run</code> option for testing</li><li>Remove use of deprecated <code>pexpect</code> methods</li><li>Add and update some error messages</li></ul> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2008/05/website-backup-script-bug-fix-release/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>How-to import a Maildir++ folder to Kmail</title><link>http://kevin.deldycke.com/2007/11/how-to-import-a-maildir-folder-to-kmail/</link> <comments>http://kevin.deldycke.com/2007/11/how-to-import-a-maildir-folder-to-kmail/#comments</comments> <pubDate>Mon, 26 Nov 2007 22:21:18 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[Backup]]></category> <category><![CDATA[KDE]]></category> <category><![CDATA[kmail]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[mail]]></category> <category><![CDATA[mailbox]]></category> <category><![CDATA[maildir]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[Script]]></category><guid isPermaLink="false">http://kevin.deldycke.com/2007/11/how-to-import-a-maildir-folder-to-kmail/</guid> <description><![CDATA[Let&#8217;s say you have a local copy of a mail folder you want to browse with Kmail. This folder is normally found on a dedicated mail server and you access it through the IMAP protocol. I was in this situation &#8230; <a href="http://kevin.deldycke.com/2007/11/how-to-import-a-maildir-folder-to-kmail/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Let&#8217;s say you have a local copy of a mail folder you want to browse with <a href="http://kontact.kde.org/kmail">Kmail</a>. This folder is normally found on a dedicated mail server and you access it through the IMAP protocol. I was in this situation some days ago and I will tell you how I&#8217;ve done it.</p><p>Instinctively, I assumed that my folder was of the <a href="http://en.wikipedia.org/wiki/Maildir">Maildir format</a>, and Kmail local mails too. So I tried to copy my <code>~/Maildir</code> folder from the mail server to my local machine (<code>~/.kde/share/apps/kmail/mail/</code>). And that was the result in Kmail:</p><p><img class="center" src='http://kevin.deldycke.com/wp-content/uploads/2007/11/kmail-no-sub-folders.png' alt='kmail-no-sub-folders.png' /></p><p>It looks good but it&#8217;s not: there is no sub-folders !</p><p>After some googling, I found what was wrong: my <code>~/Maildir</code> folder is not a Maildir, but a <a href="http://www.inter7.com/courierimap/README.maildirquota.html">Maildir++</a> folder. This kind of folder is handle by popular IMAP <a href="http://en.wikipedia.org/wiki/Mail_transfer_agent">MTA</a> like <a href="http://cr.yp.to/qmail.html">qmail</a>, <a href="http://www.dovecot.org">Dovecot</a> and <a href="http://www.courier-mta.org">courier-imap</a> (which was used on the mail server where my <code>~/Maildir</code> come from). There is some advantages of using the &#8220;<code>++</code>&#8221; flavor of Maildir over the classic one, like quotas and sub-folders. Unfortunately <a href="http://groups.google.com/group/comp.windows.x.kde/browse_thread/thread/1c74818b4175b3ec#487b5c78311a07c7">Kmail is not able to read the Maildir++ folder structure</a>.</p><p>To fix this, I&#8217;ve created a tiny python <a href="http://github.com/kdeldycke/scripts/blob/master/maildir%2B%2B2kmail.py">script to migrate a Maildir++ folder to Kmail</a>.</p><p>How-to use it ? Simply:</p><ol><li><a href="http://github.com/kdeldycke/scripts/blob/master/maildir%2B%2B2kmail.py">Download it</a> to your disk,</li><li>Edit it and change the <code>MAILDIR_SOURCE</code> and <code>KMAILDIR_DEST</code> variables to match your local configuration,</li><li>Give it execution privileges,</li><li>Run it !</li></ol><p>I advise you to try it first in a safe environment (like under a temporary user account). And don&#8217;t forget to backup everything before playing with it: because this script work for me doesn&#8217;t mean that it will work for you ! <img src='http://kevin.deldycke.com/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /></p> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2007/11/how-to-import-a-maildir-folder-to-kmail/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> <item><title>System backup script: no more endless lock</title><link>http://kevin.deldycke.com/2007/08/system-backup-script-no-more-endless-lock/</link> <comments>http://kevin.deldycke.com/2007/08/system-backup-script-no-more-endless-lock/#comments</comments> <pubDate>Sun, 12 Aug 2007 15:00:45 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[Backup]]></category> <category><![CDATA[CLI]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[rdiff-backup]]></category> <category><![CDATA[rsync]]></category> <category><![CDATA[Script]]></category> <category><![CDATA[SSH]]></category> <category><![CDATA[system]]></category><guid isPermaLink="false">http://kevin.deldycke.com/2007/08/system-backup-script-no-more-endless-lock/</guid> <description><![CDATA[I&#8217;ve just released a new version of my system-backup.py script. The main update is about the lock file, which I implemented in the last version to keep the script to run twice (or more) in parallel. This is a nice &#8230; <a href="http://kevin.deldycke.com/2007/08/system-backup-script-no-more-endless-lock/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>I&#8217;ve just released a <a href="http://kevin.deldycke.com/static/scripts/system-backup-2007_08_12.py">new version of my <code>system-backup.py</code> script</a>.</p><p>The main update is about the lock file, which I implemented in the <a href="http://kevin.deldycke.com/2007/04/system-backup-auto-clean-and-lock-added/">last version</a> to keep the script to run twice (or more) in parallel. This is a nice feature to avoid overlapping processes that fight each other to use the same ressources. But in some extreme cases (reboot or power failure during backup, &#8230;), the lock file will remain and so will prevent the script to start (until you notice the problem and remove the lock file manually). This new version take care of this problem and is now able to remove the lock automatically if a timeout is reached. It also kill all remaining child processes.</p><p>Here is the detailed changelog:</p><ul><li>Auto-kill the script if the backup process take to much time. Timeout can be defined via a constant.</li><li>Clean kill: track all child processes to kill them safely before removing the lock file.</li><li>Require newer versions of python (>= v2.4), rsync (>= v2.6.7) and rdiff-backup (>= v1.1.0).</li><li>Use <code>--preserve-numerical-ids</code> option when adding rdiff-backup increment.</li><li>Keep 15 increments by default instead of 20. This value can be easily changed thanks to a defined constant.</li><li>Remove deleted file first during mirroring and delete outdated increments before adding a new one to gain space. This strategy is safer for target disk with low remaining free space.</li><li>Tell rsync to print human-readable values.</li></ul> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2007/08/system-backup-script-no-more-endless-lock/feed/</wfw:commentRss> <slash:comments>3</slash:comments> </item> <item><title>System Backup: Auto-Clean and Lock added</title><link>http://kevin.deldycke.com/2007/04/system-backup-auto-clean-and-lock-added/</link> <comments>http://kevin.deldycke.com/2007/04/system-backup-auto-clean-and-lock-added/#comments</comments> <pubDate>Fri, 27 Apr 2007 19:41:51 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[Backup]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[Python]]></category> <category><![CDATA[rdiff-backup]]></category> <category><![CDATA[rsync]]></category> <category><![CDATA[system]]></category><guid isPermaLink="false">http://kevin.deldycke.com/2007/04/system-backup-auto-clean-and-lock-added/</guid> <description><![CDATA[I&#8217;ve updated the system backup script I&#8217;ve released 3 weeks ago to let it clean automatically rdiff-backup folders. This is mandatory because incremental backup process is transactionnal and a power failure or a reboot can break the consistency of the &#8230; <a href="http://kevin.deldycke.com/2007/04/system-backup-auto-clean-and-lock-added/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>I&#8217;ve updated the <a href="http://kevin.deldycke.com/2007/04/system-backup-on-unreliable-link-thanks-to-rdiff-backup-and-rsync/">system backup script I&#8217;ve released 3 weeks ago</a> to let it clean automatically <code>rdiff-backup</code> folders. This is mandatory because incremental backup process is transactionnal and a power failure or a reboot can break the consistency of the <code>rdiff-backup</code> data repository. So even if such a misfortune happened, the script will be able to revert backups to a previously consistent state.</p><p>I&#8217;ve also added a locking mechanism to prevent the script to be run twice on the same machine. I&#8217;ve added this feature because I start my script every day thanks to <code>cron</code> and some backups can take more than one day.</p><p>Finally, all <code>rsync</code> commands will now be run first to reduce the time-window during which all external machines are reached and, as mentionned above, because <code>rdiff-backup</code> can take lots of time to finish its job.</p><p>Here is a <a href="http://kevin.deldycke.com/static/scripts/system-backup-2007_04_27.py">direct link to the new version of the script</a>. You can also find it in <a href="http://kevin.deldycke.com/code/">my page dedicated to various linux scripts</a>.</p> ]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2007/04/system-backup-auto-clean-and-lock-added/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>How-to Backup / Mirror a public SVN repository</title><link>http://kevin.deldycke.com/2007/04/how-to-backup-mirror-a-public-svn-repository/</link> <comments>http://kevin.deldycke.com/2007/04/how-to-backup-mirror-a-public-svn-repository/#comments</comments> <pubDate>Fri, 20 Apr 2007 17:09:26 +0000</pubDate> <dc:creator>Kev</dc:creator> <category><![CDATA[English]]></category> <category><![CDATA[Backup]]></category> <category><![CDATA[Linux]]></category> <category><![CDATA[SCM]]></category> <category><![CDATA[Subversion]]></category> <category><![CDATA[svk]]></category><guid isPermaLink="false">http://kevin.deldycke.com/2007/04/how-to-backup-mirror-a-public-svn-repository/</guid> <description><![CDATA[In this little how-to I will show you how to backup a public SVN repository thanks to SVK, a tool build upon SVN framework that add decentralized capabilities. First, create a local repository: SVK will ask you to create a &#8230; <a href="http://kevin.deldycke.com/2007/04/how-to-backup-mirror-a-public-svn-repository/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>In this little how-to I will show you how to backup a public SVN repository thanks to <a href="http://svk.bestpractical.com">SVK</a>, a tool build upon SVN framework that add decentralized capabilities.</p><p>First, create a local repository:</p><pre class="brush: bash; title: ; notranslate">
svk mirror //local https://username@svn.kde.org/home/kde
</pre><p>SVK will ask you to create a new repository. Tell it you want so:</p><pre class="brush: bash; title: ; notranslate">
Repository /home/user/.svk/local does not exist, create? (y/n) y
</pre><p>Then, sync the remote repository with the local one:</p><pre class="brush: bash; title: ; notranslate">
svk sync //local
</pre><p>That&#8217;s all !</p><p>To update your locale repository with the latest set of changes from the remote one, just run the previous command from time to time.</p><p>Now you can play with your local repository (<code>/home/user/.svk/local</code> in this exemple) as if it was a normal SVN repository !</p><p><strong><u>Update</u></strong>: If you want to generate a vanilla SVN dump out of your SVK local mirror, as suggest by <a href="http://moelhave.dk">Thomas Mølhave</a> in his &#8220;<a href="http://moelhave.dk/2006/07/remote-mirroring-a-subversion-svn-repository/">Remote Backup Of A Subversion (svn) Repository</a>&#8221; blog post, use <code>svnadmin</code>:</p><pre class="brush: bash; title: ; notranslate">
svnadmin dump -r2:HEAD ~/.svk/local &gt; my-repository-dump
</pre>]]></content:encoded> <wfw:commentRss>http://kevin.deldycke.com/2007/04/how-to-backup-mirror-a-public-svn-repository/feed/</wfw:commentRss> <slash:comments>2</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 2/46 queries in 0.018 seconds using apc
Object Caching 1123/1235 objects using apc

Served from: kevin.deldycke.com @ 2012-02-08 10:19:07 -->
