<?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>Le Vosgien du Net &#187; firebird</title>
	<atom:link href="http://levosgien.net/tag/firebird/feed/" rel="self" type="application/rss+xml" />
	<link>http://levosgien.net</link>
	<description>Parce que la vérité n'est pas toujours bonne à dire</description>
	<lastBuildDate>Thu, 11 Feb 2010 18:39:29 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Improving FBClone Performance</title>
		<link>http://levosgien.net/2010/02/11/improving-fbclone-performance/</link>
		<comments>http://levosgien.net/2010/02/11/improving-fbclone-performance/#comments</comments>
		<pubDate>Thu, 11 Feb 2010 18:39:29 +0000</pubDate>
		<dc:creator>Pierre</dc:creator>
				<category><![CDATA[Geekitude]]></category>
		<category><![CDATA[delphi]]></category>
		<category><![CDATA[fbclone]]></category>
		<category><![CDATA[firebird]]></category>
		<category><![CDATA[uib]]></category>

		<guid isPermaLink="false">http://levosgien.net/?p=196</guid>
		<description><![CDATA[	I added some code to track down where FBClone spends most of it&#8217;s time.
	You can download FBClone v1.5 and try with the verbose option, it will log tons of funny things on the console so you will not have to go for a beer  
	If you see something interresting, please send my your output [...]]]></description>
			<content:encoded><![CDATA[	<p>I added some code to track down where FBClone spends most of it&#8217;s time.</p>
	<p>You can download <a href='http://levosgien.net/wp/wp-content/uploads/2010/02/FBClone_1.5.0.0.zip'>FBClone v1.5</a> and try with the verbose option, it will log tons of funny things on the console so you will not have to go for a beer <img src='http://levosgien.net/wp/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
	<p>If you see something interresting, please send my your output log by email (pierre at levosgien dotnet)</p>
	<p>Thank you for your help !</p>

 ]]></content:encoded>
			<wfw:commentRss>http://levosgien.net/2010/02/11/improving-fbclone-performance/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cloning Firebird Databases</title>
		<link>http://levosgien.net/2010/02/10/cloning-firebird-databases/</link>
		<comments>http://levosgien.net/2010/02/10/cloning-firebird-databases/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 10:07:05 +0000</pubDate>
		<dc:creator>Pierre</dc:creator>
				<category><![CDATA[Geekitude]]></category>
		<category><![CDATA[delphi]]></category>
		<category><![CDATA[firebird]]></category>
		<category><![CDATA[uib]]></category>

		<guid isPermaLink="false">http://levosgien.net/?p=181</guid>
		<description><![CDATA[	Repairing broken Firebird database can be sometimes a bit difficult. The official tools (gfix and gbak) not always can help you so you will have to find ways to transfer data from broken database into another fresh and clean one.
	There are some tools that can help you :

IB Datapump that is a bit old an [...]]]></description>
			<content:encoded><![CDATA[	<p>Repairing broken Firebird database can be sometimes a bit difficult. The official tools (gfix and gbak) not always can help you so you will have to find ways to transfer data from broken database into another fresh and clean one.</p>
	<p>There are some tools that can help you :<br />
<ul><br />
<li><a href="http://www.clevercomponents.com/products/datapump/ibdatapump.asp">IB Datapump</a> that is a bit old an not very fine tuned to access broken databases</li><br />
<li><a href="http://www.firebirdfaq.org/fbcopy.php">FB Copy</a> that lacks options to access broken databases too.</li><br />
</ul></p>
	<p>If your database is heavily broken, you will have to fire out the heavy artillery and buy some commercial products like <a href="http://ib-aid.com/products/firebird_interbase/IBFirstAID-FBFirstAID">IBFirstAid</a>.</p>
	<p>This incredible piece of software will walk throught your database, finding errors and inconsistencies, fix them so you will, probably be able to access your databasa again with gfix and gbak.</p>
	<p>I&#8217;ve written my own database cloning tool for Firebird. It&#8217;s named FBClone, it&#8217;s written with Delphi and uses the wonderful <a href="http://sourceforge.net/projects/uib">UIB Components</a> from <a href="http://www.progdigy.com/">Progdigy</a>.</p>
	<p>Features :<br />
<ul><br />
<li>Clone a whole database like a backup (gbak -b) and a restore (gbak -c) in a single pass</li><br />
<li>Pump data from a source database into another one with the same structure. A database with the same structure can be created with gbak using the option &#8221;-m&#8221; to restore metadata only.</li><br />
<li>Change database and data charset, converting an old Firebird 1.5 ISO8859_1 database into a fresh new Firebird 2.1 UTF8 one.</li><br />
</ul></p>
	<p>You can download <a href='http://levosgien.net/wp/wp-content/uploads/2010/02/FBClone_1.4.0.0.zip'>FBClone 1.4 Source and Windows Executable</a>.</p>
	<p><strong>[Edit]</strong> Updated FBClone to v1.4<br />
<em>ChangeLog :</em><br />
<ul><br />
<li>Support Firebird 2.1+</li><br />
<li>Improved output</li><br />
<li>Allow to change target database page size (example : -ps 8192)</li><br />
<li>English is the default language for the application now.</li> <br />
</ul></p>
	<p><strong>[Edit]</strong> The code is shared under the IDPL &#8211; <a href="http://www.firebirdsql.org/index.php?op=doc&#38;id=idpl">Initial Developer Public License</a> &#8211; Thank you for sharing your modifications.</p>

 ]]></content:encoded>
			<wfw:commentRss>http://levosgien.net/2010/02/10/cloning-firebird-databases/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Switch between versions of Firebird SQL Server</title>
		<link>http://levosgien.net/2009/12/01/switch-between-versions-of-firebird-sql-server/</link>
		<comments>http://levosgien.net/2009/12/01/switch-between-versions-of-firebird-sql-server/#comments</comments>
		<pubDate>Tue, 01 Dec 2009 15:19:31 +0000</pubDate>
		<dc:creator>Pierre</dc:creator>
				<category><![CDATA[Geekitude]]></category>
		<category><![CDATA[Non classé]]></category>
		<category><![CDATA[firebird]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://levosgien.net/?p=172</guid>
		<description><![CDATA[	I wrote a little batch script to switch between versions of Firebird SQL Server nearly automatically.

The only one requirement is that all versions must be installed in C:\Program Files\Firebird\&#60;Version&#62; where  is Major.Minor version number of the Firebird Server you want to use.
	Eg : C:\Program Files\Firebird\1.5, C:\Program Files\Firebird\2.0, C:\Program Files\Firebird\2.1 ...
	Just copy the script in [...]]]></description>
			<content:encoded><![CDATA[	<p>I wrote a little batch script to switch between versions of <a href="http://www.firebirdsql.org">Firebird SQL Server</a> nearly automatically.<br />
<span id="more-172"></span><br />
The only one requirement is that all versions must be installed in <code>C:\Program Files\Firebird\&lt;Version&gt;</code> where <Version> is <code>Major.Minor</code> version number of the Firebird Server you want to use.</p>
	<p>Eg : <code>C:\Program Files\Firebird\1.5</code>, <code>C:\Program Files\Firebird\2.0</code>, <code>C:\Program Files\Firebird\2.1</code> ...</p>
	<p>Just copy the script in C:\Program Files\Firebird and start switching between versions of Firebird :</p>
	<p>C:\Program Files\Firebird\> switch 1.5<br />
C:\Program Files\Firebird\> switch 2.0<br />
...</p>
	<p>The code :</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">@</span><span style="color: #7a0874; font-weight: bold;">echo</span> off
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #ff0000;">&quot;%OLD_PATH%&quot;</span> == <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>
  <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">OLD_PATH</span>=<span style="color: #000000; font-weight: bold;">%</span>PATH<span style="color: #000000; font-weight: bold;">%</span>
<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
setlocal
&nbsp;
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">FB_KEY</span>=HKLM\SOFTWARE\Firebird Project\Firebird Server\Instances
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">FB_VALUE</span>=DefaultInstance
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #000000; font-weight: bold;">/</span>F <span style="color: #ff0000;">&quot;skip=2 tokens=2*&quot;</span> <span style="color: #000000; font-weight: bold;">%%</span>A IN <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'reg query &quot;%FB_KEY%&quot; /v %FB_VALUE%'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>
  <span style="color: #000000; font-weight: bold;">for</span> <span style="color: #000000; font-weight: bold;">/</span>F <span style="color: #ff0000;">&quot;delims=\ tokens=4&quot;</span> <span style="color: #000000; font-weight: bold;">%%</span>Y IN <span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #ff0000;">'echo %%B'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">do</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>
    <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">CURRENT_FB</span>=<span style="color: #000000; font-weight: bold;">%%</span>Y
  <span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">VERSION</span>=<span style="color: #000000; font-weight: bold;">%</span>1
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #ff0000;">&quot;%VERSION%&quot;</span> == <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> Syntax : <span style="color: #000000; font-weight: bold;">%</span>0 <span style="color: #7a0874; font-weight: bold;">&#91;</span><span style="color: #000000;">1.5</span> ^<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">2.0</span> ^<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">2.1</span> ^<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">2.5</span> ^<span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000;">3.0</span><span style="color: #7a0874; font-weight: bold;">&#93;</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span>Params <span style="color: #000000; font-weight: bold;">for</span> instsvc i^<span style="color: #7a0874; font-weight: bold;">&#40;</span>nstall^<span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#93;</span>
  <span style="color: #000000; font-weight: bold;">if</span> not <span style="color: #000000; font-weight: bold;">%</span>CURRENT_FB<span style="color: #000000; font-weight: bold;">%</span> == <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>
    <span style="color: #000000; font-weight: bold;">if</span> exist <span style="color: #000000; font-weight: bold;">%</span>CURRENT_FB<span style="color: #000000; font-weight: bold;">%</span>\bin\instsvc.exe <span style="color: #7a0874; font-weight: bold;">&#40;</span>
      echo.
      <span style="color: #7a0874; font-weight: bold;">echo</span> Tip : These are the available options <span style="color: #000000; font-weight: bold;">for</span> instsvc from Firebird <span style="color: #000000; font-weight: bold;">%</span>CURRENT_FB<span style="color: #000000; font-weight: bold;">%</span>
      <span style="color: #000000; font-weight: bold;">%</span>CURRENT_FB<span style="color: #000000; font-weight: bold;">%</span>\bin\instsvc.exe
    <span style="color: #7a0874; font-weight: bold;">&#41;</span>
  <span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#41;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>
  <span style="color: #000000; font-weight: bold;">if</span> not <span style="color: #ff0000;">&quot;%CURRENT_FB%&quot;</span> == <span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#40;</span>
    <span style="color: #7a0874; font-weight: bold;">echo</span> Unregistering Firebird <span style="color: #000000; font-weight: bold;">%</span>CURRENT_FB<span style="color: #000000; font-weight: bold;">%</span>
&nbsp;
    <span style="color: #7a0874; font-weight: bold;">pushd</span> <span style="color: #000000; font-weight: bold;">%</span>CURRENT_FB<span style="color: #000000; font-weight: bold;">%</span>\bin
    instclient r g
    instsvc stop
    instsvc r
    instreg r
    <span style="color: #7a0874; font-weight: bold;">popd</span>  
&nbsp;
    echo.
  <span style="color: #7a0874; font-weight: bold;">&#41;</span>
&nbsp;
  <span style="color: #7a0874; font-weight: bold;">echo</span> Registering Firebird <span style="color: #000000; font-weight: bold;">%</span>VERSION<span style="color: #000000; font-weight: bold;">%</span>
&nbsp;
  <span style="color: #7a0874; font-weight: bold;">pushd</span> <span style="color: #000000; font-weight: bold;">%</span>VERSION<span style="color: #000000; font-weight: bold;">%</span>\bin  
  instreg i <span style="color: #660033;">-z</span>
  instsvc i <span style="color: #000000; font-weight: bold;">%</span>2 <span style="color: #000000; font-weight: bold;">%</span>3 <span style="color: #000000; font-weight: bold;">%</span>4 <span style="color: #000000; font-weight: bold;">%</span>5 <span style="color: #000000; font-weight: bold;">%</span>6 <span style="color: #000000; font-weight: bold;">%</span>7 <span style="color: #000000; font-weight: bold;">%</span>8 <span style="color: #000000; font-weight: bold;">%</span>9
  instsvc start
  instclient i g
  <span style="color: #7a0874; font-weight: bold;">popd</span>
&nbsp;
  echo.
&nbsp;
  <span style="color: #7a0874; font-weight: bold;">echo</span> Defining System Path to search <span style="color: #000000; font-weight: bold;">in</span> Firebird <span style="color: #000000; font-weight: bold;">%</span>VERSION<span style="color: #000000; font-weight: bold;">%</span> tools and some useful environment variables
&nbsp;
  endlocal 
  <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">PATH</span>=<span style="color: #000000; font-weight: bold;">%</span>OLD_PATH<span style="color: #000000; font-weight: bold;">%</span>;<span style="color: #ff0000;">&quot;%CD%\%VERSION%\bin&quot;</span>
  <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">ISC_USER</span>=SYSDBA
  <span style="color: #000000; font-weight: bold;">set</span> <span style="color: #007800;">ISC_PASSWORD</span>=masterkey
&nbsp;
  <span style="color: #7a0874; font-weight: bold;">echo</span> All Right <span style="color: #000000; font-weight: bold;">!</span>
<span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></div></div>

	<p>Hope this helps <img src='http://levosgien.net/wp/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>


 ]]></content:encoded>
			<wfw:commentRss>http://levosgien.net/2009/12/01/switch-between-versions-of-firebird-sql-server/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Tunnelling a Firebird Backup with SSH</title>
		<link>http://levosgien.net/2009/06/17/tunnelling-a-firebird-backup-with-ssh/</link>
		<comments>http://levosgien.net/2009/06/17/tunnelling-a-firebird-backup-with-ssh/#comments</comments>
		<pubDate>Wed, 17 Jun 2009 14:43:07 +0000</pubDate>
		<dc:creator>Pierre</dc:creator>
				<category><![CDATA[Geekitude]]></category>
		<category><![CDATA[Vôsgitude]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[compression]]></category>
		<category><![CDATA[firebird]]></category>
		<category><![CDATA[restore]]></category>
		<category><![CDATA[ssh]]></category>
		<category><![CDATA[tunnel]]></category>

		<guid isPermaLink="false">http://levosgien.net/?p=159</guid>
		<description><![CDATA[	SSH is a wonderful piece of software. I found (hum, Philippe, the CentOS package maintainer, president of the Firebird Foundation and member of the QA team of Firebird helped me to find) how to create a SSH tunnel through I can run a distant Firebird backup.
	This is the standard gbak command :
$ gbak -b [-v] [...]]]></description>
			<content:encoded><![CDATA[	<p>SSH is a wonderful piece of software. I found (hum, <a href="http://pmakowski.ibphoenix.fr/">Philippe, the CentOS package maintainer, president of the Firebird Foundation and member of the QA team of Firebird</a> helped me to find) how to create a SSH tunnel through I can run a distant Firebird backup.</p>
	<p>This is the standard gbak command :</p>
<code>$ gbak -b [-v] XXX.XXX.XXX.XXX:database backup.fbk -user SYSDBA -password masterkey</code>
	<p>With that command you can create a LOCAL backup of a REMOTE database.</p>
	<p>With this command :</p>
<code>$ gbak -b [-v] -service XXX.XXX.XXX.XXX:service_mgr database /path/to/backup.fbk -user SYSDBA -password masterkey </code>
	<p>You will create a REMOTE backup (in /path/to/backup.fbk) of a REMOTE database.</p>
	<p>Now, how can I create a LOCAL backup for a REMOTE database with stream compression and encryption ? By using SSH Tunnelling.</p>
<code>$ ssh -C -f user@XXX.XXX.XXX.XXX -L 3052:localhost:3050 -N</code>
	<p>This will run a background (-f) SSH Tunnel (-L) mapping local port 3052 to remote port 3050 (3052:localhost:3050) with compression (-C, or -o Compression=yes) and without running a remote command (-N)</p>
	<p>Now we can use this tunnel to start a secured/compressed remote backup :</p>
<code>$ gbak -b [-v] localhost/3052:database backup.fbk -user SYSDBA password masterkey</code>
	<p>Note : &#8220;database&#8221; can be an alias name, if defined in /etc/firebird/aliases.conf (location depends on your distribution package maintainer, at least this is where I can find this file on CentOS 5.3 using EPEL Testing repository) or the full path of the database on the host system. &#8220;backup.fbk&#8221; is the local path of the backup file.</p>
	<p>You will restore this backup locally by using this command :</p>
<code>$ gbak -c [-v] backup.fbk database -user SYSDBA -password masterkey</code>
	<p>Of course, you will have to adjust the user/password depending on your own configuration.</p>

 ]]></content:encoded>
			<wfw:commentRss>http://levosgien.net/2009/06/17/tunnelling-a-firebird-backup-with-ssh/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Firebird backup script</title>
		<link>http://levosgien.net/2008/09/25/firebird-backup-script/</link>
		<comments>http://levosgien.net/2008/09/25/firebird-backup-script/#comments</comments>
		<pubDate>Thu, 25 Sep 2008 09:29:59 +0000</pubDate>
		<dc:creator>Pierre</dc:creator>
				<category><![CDATA[Geekitude]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[firebird]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[scripting]]></category>

		<guid isPermaLink="false">http://levosgien.net/?p=123</guid>
		<description><![CDATA[	This is my first released backup script for Firebird RDBMS. It automagically search for all Firebird databases from a central directory, uses gfix to validate them, then backup + gzip them to a central backup directory keeping only 5 last successful backups.
	It may be used as a cron script to automate Firebird databases backup.


#!/usr/bin/env bash
#
# [...]]]></description>
			<content:encoded><![CDATA[	<p>This is my first released backup script for Firebird RDBMS. It automagically search for all Firebird databases from a central directory, uses gfix to validate them, then backup + gzip them to a central backup directory keeping only 5 last successful backups.</p>
	<p>It may be used as a cron script to automate Firebird databases backup.<br />
<span id="more-123"></span></p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/usr/bin/env bash</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#   Validate and Backup Firebird databases using Firebird</span>
<span style="color: #666666; font-style: italic;"># standard tools</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;">#   You can adjust FB_ROOT, FB_BIN, FB_DATA, Fb_BACKUP and </span>
<span style="color: #666666; font-style: italic;"># BACKUP_COUNT variables to fit your own requirements. </span>
<span style="color: #666666; font-style: italic;"># For instance, if you use an official package of Firebird for your</span>
<span style="color: #666666; font-style: italic;"># ditribution, you may have to change FB_ROOT to /usr/bin.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># The contents of this file are subject to the Initial </span>
<span style="color: #666666; font-style: italic;"># Developer's Public License Version 1.0 (the &quot;License&quot;); </span>
<span style="color: #666666; font-style: italic;"># you may not use this file except in compliance with the </span>
<span style="color: #666666; font-style: italic;"># License. You may obtain a copy of the License from</span>
<span style="color: #666666; font-style: italic;"># the Firebird Project website, at </span>
<span style="color: #666666; font-style: italic;"># http://www.firebirdsql.org/index.php?op=doc&amp;id=idpl.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Software distributed under the License is distributed </span>
<span style="color: #666666; font-style: italic;"># on an &quot;AS IS&quot; basis, WITHOUT WARRANTY OF ANY KIND, </span>
<span style="color: #666666; font-style: italic;"># either express or implied. See the License for the </span>
<span style="color: #666666; font-style: italic;"># specific language governing rights and limitations under </span>
<span style="color: #666666; font-style: italic;"># the License.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># The Original Code is licenced under IDPL</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># The Initial Developer of the Original Code is </span>
<span style="color: #666666; font-style: italic;">#   Pierre Yager (pierre@levosgien.net).</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Portions created by ______________________</span>
<span style="color: #666666; font-style: italic;"># are Copyright (C) ______ _________________.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># All Rights Reserved.</span>
<span style="color: #666666; font-style: italic;">#</span>
<span style="color: #666666; font-style: italic;"># Contributor(s): _________________________.</span>
<span style="color: #666666; font-style: italic;">#</span>
&nbsp;
<span style="color: #007800;">FB_ROOT</span>=<span style="color: #000000; font-weight: bold;">/</span>opt<span style="color: #000000; font-weight: bold;">/</span>firebird
<span style="color: #007800;">FB_BIN</span>=<span style="color: #800000;">${FB_ROOT}</span><span style="color: #000000; font-weight: bold;">/</span>bin
<span style="color: #007800;">FB_DATA</span>=<span style="color: #000000; font-weight: bold;">/</span>var<span style="color: #000000; font-weight: bold;">/</span>firebird
<span style="color: #007800;">FB_BACKUP</span>=backup
<span style="color: #007800;">BACKUP_COUNT</span>=<span style="color: #000000;">5</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># You shouldn't have to make any changes below</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">id</span> -u<span style="color: #000000; font-weight: bold;">`</span> = <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> You are not root...
  <span style="color: #7a0874; font-weight: bold;">exit</span> <span style="color: #000000;">67</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Loads the ISC_USER and ISC_PASSWORD environment variables</span>
<span style="color: #7a0874; font-weight: bold;">source</span> <span style="color: #800000;">${FB_ROOT}</span><span style="color: #000000; font-weight: bold;">/</span>SYSDBA.password
&nbsp;
<span style="color: #7a0874; font-weight: bold;">export</span> ISC_USER
<span style="color: #7a0874; font-weight: bold;">export</span> ISC_PASSWORD
&nbsp;
<span style="color: #666666; font-style: italic;">#  Returns the filename without extension, whatever the </span>
<span style="color: #666666; font-style: italic;">#+ extension is...</span>
<span style="color: #000000; font-weight: bold;">function</span> namename<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">name</span>=<span style="color: #800000;">${1##*/}</span>
  <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">name0</span>=<span style="color: #ff0000;">&quot;<span style="color: #007800;">${name%.*}</span>&quot;</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">${name0:-$name}</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Cleanup old backup files</span>
<span style="color: #000000; font-weight: bold;">function</span> cleanup<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">PREFIX</span>=$<span style="color: #000000;">1</span>
&nbsp;
  <span style="color: #666666; font-style: italic;"># list files by time in reverse order </span>
  <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">FILES</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-rt</span> <span style="color: #800000;">${FB_BACKUP}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${PREFIX}</span><span style="color: #000000; font-weight: bold;">*</span>.fbk.gz<span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
  <span style="color: #666666; font-style: italic;"># count the previous files list</span>
  <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">FILES_COUNT</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">ls</span> <span style="color: #660033;">-lrt</span> <span style="color: #800000;">${FB_BACKUP}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${PREFIX}</span><span style="color: #000000; font-weight: bold;">*</span>.fbk.gz <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">wc</span> -l<span style="color: #000000; font-weight: bold;">`</span>
&nbsp;
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$FILES_COUNT</span> <span style="color: #660033;">-gt</span> <span style="color: #007800;">$BACKUP_COUNT</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
  <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #666666; font-style: italic;"># Iterate the files list</span>
    <span style="color: #000000; font-weight: bold;">for</span> F <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$FILES</span>
    <span style="color: #000000; font-weight: bold;">do</span>
      <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #007800;">$FILES_COUNT</span> <span style="color: #660033;">-gt</span> <span style="color: #007800;">$BACKUP_COUNT</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
      <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #666666; font-style: italic;">#  And remove first files as soon as we have only </span>
        <span style="color: #666666; font-style: italic;">#+ BACKUP_COUNT files remaining</span>
        <span style="color: #c20cb9; font-weight: bold;">rm</span> <span style="color: #007800;">$F</span>
        <span style="color: #007800;">FILES_COUNT</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>FILES_COUNT - <span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
      <span style="color: #000000; font-weight: bold;">else</span>
        <span style="color: #7a0874; font-weight: bold;">break</span>
      <span style="color: #000000; font-weight: bold;">fi</span>
    <span style="color: #000000; font-weight: bold;">done</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Uses gfix to validates the database</span>
<span style="color: #000000; font-weight: bold;">function</span> validate<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #800000;">${FB_BIN}</span><span style="color: #000000; font-weight: bold;">/</span>gfix <span style="color: #660033;">-validate</span> <span style="color: #660033;">-full</span> $<span style="color: #000000;">1</span>
  <span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #007800;">$?</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;"># Uses gbak to backup the database then compress it...</span>
<span style="color: #000000; font-weight: bold;">function</span> backup<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
<span style="color: #7a0874; font-weight: bold;">&#123;</span>
  <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">DIR</span>=<span style="color: #800000;">${1%/*}</span>
  <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">DB</span>=<span style="color: #000000; font-weight: bold;">`</span>namename <span style="color: #007800;">$F</span><span style="color: #000000; font-weight: bold;">`</span>
  <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">TS</span>=<span style="color: #000000; font-weight: bold;">`</span><span style="color: #c20cb9; font-weight: bold;">date</span> +<span style="color: #ff0000;">&quot;%Y%m%d_%H%M%S&quot;</span><span style="color: #000000; font-weight: bold;">`</span>
  <span style="color: #7a0874; font-weight: bold;">local</span> <span style="color: #007800;">BACKUP</span>=<span style="color: #800000;">${FB_BACKUP}</span><span style="color: #000000; font-weight: bold;">/</span><span style="color: #800000;">${DIR}</span>_<span style="color: #800000;">${DB}</span>_<span style="color: #800000;">${TS}</span>.fbk
  <span style="color: #800000;">${FB_BIN}</span><span style="color: #000000; font-weight: bold;">/</span>gbak <span style="color: #660033;">-b</span> $<span style="color: #000000;">1</span> <span style="color: #007800;">$BACKUP</span>
  <span style="color: #c20cb9; font-weight: bold;">gzip</span> <span style="color: #007800;">$BACKUP</span>
  cleanup <span style="color: #800000;">${DIR}</span>_<span style="color: #800000;">${DB}</span>
<span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">pushd</span> <span style="color: #800000;">${FB_DATA}</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
&nbsp;
<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">!</span> <span style="color: #660033;">-d</span> <span style="color: #800000;">${FB_BACKUP}</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
<span style="color: #000000; font-weight: bold;">then</span>
  <span style="color: #c20cb9; font-weight: bold;">mkdir</span> <span style="color: #800000;">${FB_BACKUP}</span>
<span style="color: #000000; font-weight: bold;">fi</span>
&nbsp;
<span style="color: #666666; font-style: italic;">#  Avoid */*.fdb to be expanded if there are no files in the </span>
<span style="color: #666666; font-style: italic;">#+ databases repository</span>
<span style="color: #7a0874; font-weight: bold;">shopt</span> <span style="color: #660033;">-s</span> nullglob
&nbsp;
<span style="color: #000000; font-weight: bold;">for</span> F <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #000000; font-weight: bold;">*/*</span>.fdb
<span style="color: #000000; font-weight: bold;">do</span>
  <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> <span style="color: #000000; font-weight: bold;">`</span>validate <span style="color: #007800;">$F</span><span style="color: #000000; font-weight: bold;">`</span> = <span style="color: #000000;">0</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
  <span style="color: #000000; font-weight: bold;">then</span>
    <span style="color: #666666; font-style: italic;"># Only backup valid databases</span>
    backup <span style="color: #007800;">$F</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">#  Future enhancements : write a message to stderr so that</span>
    <span style="color: #666666; font-style: italic;">#+ cron can send a mail to the DBA when databases are not </span>
    <span style="color: #666666; font-style: italic;">#+ valid...</span>
  <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span>
&nbsp;
<span style="color: #7a0874; font-weight: bold;">popd</span> <span style="color: #000000; font-weight: bold;">&gt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null</pre></div></div>

	<p>Hope this will be useful. You can also <a href="http://levosgien.net/files/fb-backup.sh">download the script</a></p>

 ]]></content:encoded>
			<wfw:commentRss>http://levosgien.net/2008/09/25/firebird-backup-script/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
