<?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>DJS Consulting Tech Blog &#187; PostgreSQL</title>
	<atom:link href="http://djs-consulting.com/linux/blog/category/databases/postgresql/feed" rel="self" type="application/rss+xml" />
	<link>http://djs-consulting.com/linux/blog</link>
	<description>Technical Information You Can Use (or not - but hey, at least it&#039;s free!)</description>
	<lastBuildDate>Tue, 02 Mar 2010 19:11: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>Oracle SQL Developer Debian Package</title>
		<link>http://djs-consulting.com/linux/blog/2008/oracle-sql-developer-debian-package</link>
		<comments>http://djs-consulting.com/linux/blog/2008/oracle-sql-developer-debian-package#comments</comments>
		<pubDate>Wed, 29 Oct 2008 13:17:13 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[MySQL]]></category>
		<category><![CDATA[Oracle]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[deb]]></category>
		<category><![CDATA[debian]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[rpm]]></category>
		<category><![CDATA[sql developer]]></category>
		<category><![CDATA[toad]]></category>
		<category><![CDATA[ubuntu]]></category>

		<guid isPermaLink="false">http://www.djs-consulting.com/linux/blog/?p=72</guid>
		<description><![CDATA[Oracle SQL Developer is a Java-based tool that provides a graphical interface to a database.  While it&#8217;s main focus is Oracle (of course), it can be hooked up, via JDBC, to many other databases, such as MySQL, PostgreSQL, and SQL Server.  It&#8217;s similar to Toad, but is provided by Oracle at no cost.
Oracle [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.oracle.com/technology/products/database/sql_developer/index.html" title="Oracle SQL Developer &bull; Oracle">Oracle SQL Developer</a> is a Java-based tool that provides a graphical interface to a database.  While it&#8217;s main focus is Oracle (of course), it can be hooked up, via JDBC, to many other databases, such as MySQL, PostgreSQL, and SQL Server.  It&#8217;s similar to <a href="http://www.toadsoft.com/">Toad</a>, but is provided by Oracle at no cost.</p>
<p>Oracle provides SQL Developer in either an RPM, or a generic binary install.  I like the ability to manage packages, but I&#8217;ve never had much luck at getting RPM to run on Ubuntu.  I downloaded the RPM file, and, using <a href="http://kitenet.net/~joey/code/alien/">alien</a>, I converted the package to a .deb package (Debian package format) and installed it.  I worked like a charm!</p>
<p>I haven&#8217;t tested it with gcj, but using Sun&#8217;s Java 6 update 7 from the Ubuntu repositories, it ran just fine.  After you install the package, do a directory list on /usr/lib/jvm.  You&#8217;re looking for the Sun JDK &#8211; if it&#8217;s installed, you&#8217;ll have a symlink java-6-sun that points to java-6-sun-1.6.0.07.  Once you&#8217;ve determined the location of the JDK, run &#8220;sqldeveloper&#8221; from the command line &#8211; the program will prompt you for the path to your JDK.  Enter it (probably &#8220;/usr/lib/jvm/java-6-sun&#8221;) and you&#8217;re good to go.  (You have to install the package as root &#8211; but, for the rest of these steps, use your normal user, not root, as this puts settings in a .sqldeveloper directory off your home directory.)  The package installs an icon in the &#8220;Programming&#8221; or &#8220;Development&#8221; group.  Once you&#8217;ve told it where the JDK is, you can use this to launch it.</p>
<p><a href="http://www.djs-consulting.com/linux/software/sqldeveloper/sqldeveloper_1.5.54.40-2_all.deb" title="SQL Developer 1.5.1 Debian Package &bull; DJS Consulting Linux Software Repository">Download SQL Developer 1.5.1 Debian Package</a></p>
]]></content:encoded>
			<wfw:commentRss>http://djs-consulting.com/linux/blog/2008/oracle-sql-developer-debian-package/feed</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>A Handy PHP Backup Script</title>
		<link>http://djs-consulting.com/linux/blog/2008/a-handy-php-backup-script</link>
		<comments>http://djs-consulting.com/linux/blog/2008/a-handy-php-backup-script#comments</comments>
		<pubDate>Sat, 29 Mar 2008 05:06:03 +0000</pubDate>
		<dc:creator>Daniel</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[cron]]></category>
		<category><![CDATA[mysqldump]]></category>
		<category><![CDATA[pg_dump]]></category>

		<guid isPermaLink="false">http://www.djs-consulting.com/linux/blog/2008/a-handy-php-backup-script</guid>
		<description><![CDATA[I found a script over on the Lunarpages Forums about using PHP to back up your site.  I have taken it, modified it a little, beefed up the documentation a lot, and am now posting it here.  You can download the source code for it, and it is also displayed below.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
&#60;?php
/**
 * Generic [...]]]></description>
			<content:encoded><![CDATA[<p>I found a script over on the Lunarpages Forums about <a href="http://www.lunarforums.com/lunarpages_how_tos/site_and_mysql_backups_via_cron-t22118.0.html" title="Site and MySQL backups via cron - Lunarforums">using PHP to back up your site</a>.  I have taken it, modified it a little, beefed up the documentation a lot, and am now posting it here.  You can <a href="/linux/generic_backup.txt" title="Generic Backup Script">download the source code</a> for it, and it is also displayed below.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
</pre></td><td class="code"><pre class="php php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #0000ff; font-style: italic;">/**
 * Generic Backup Script.
 * 
 * To configure this script for your purposes, just edit the parameters below.
 * Once you have the parameters set properly, when the script executes, it will
 * create an archive file, gzip it, and e-mail it to the address specified.  It
 * can be executed through cron with the command
 * 
 * php -q [name of script]
 * 
 * You are free to use this, modify it, copy it, etc.  However, neither DJS
 * Consulting nor Daniel J. Summers assume any responsibility for good or bad
 * things that happen when modifications of this script are run.
 * 
 * @author Daniel J. Summers &lt;daniel@djs-consulting.com&gt;
 */</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// --- SCRIPT PARAMETERS ---</span>
&nbsp;
<span style="color: #666666; font-style: italic;">/*  -- File Name --
	This is the name of the file that you're backing up, and should contain no
	slashes.  For example, if you're backing up a database, this might look
	something like...
$sFilename = &quot;backup-my_database_name-&quot; . date(&quot;Y-m-d&quot;) . &quot;.sql&quot;; */</span>
<span style="color: #000088;">$sFilename</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;backup-[whatever-it-is]-&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">date</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Y-m-d&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;.[extension]&quot;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">/*  -- E-mail Address --
	This is the e-mail address to which the message will be sent. */</span>
<span style="color: #000088;">$sEmailAddress</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;[your e-mail address]&quot;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">/*  -- E-mail Subject --
	This is the subject that will be on the e-mail you receive. */</span>
<span style="color: #000088;">$sEmailSubject</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;[something meaningful]&quot;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">/*  -- E-mail Message --
	This is the text of the message that will be sent. */</span>
<span style="color: #000088;">$sMessage</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Compressed database backup file $sFilename.gz attached.&quot;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">/*  -- Backup Command --
	This is the command that does the work.
&nbsp;
	A note on the database commands - your setup likely requires a password
	for these commands, and they each allow you to pass a password on the
	command line.  However, this is very insecure, as anyone who runs &quot;ps&quot; can
	see your password!  For MySQL, you can create a ~/.my.cnf file - it is
	detailed at http://dev.mysql.com/doc/refman/4.1/en/password-security.html .
	For PostgreSQL, the file is ~/.pgpass, and it is detailed at
	http://www.postgresql.org/docs/8.0/interactive/libpq-pgpass.html .  Both of
	these files should be chmod-ded to 600, so that they can only be viewed by
	you, the creator.
&nbsp;
	That being said, some common commands are...
&nbsp;
- Backing Up a MySQL Database
$sBackupCommand = &quot;mysqldump -u [user_name] [db_name] &gt; $sFilename&quot;;
&nbsp;
- Backing Up a PostgreSQL Database
$sBackupCommand = &quot;pg_dump [db_name] -h localhost -U [user_name] -d -O &gt; $sFilename&quot;;
&nbsp;
- Backing Up a set of files (tar and gzip)
$sBackupCommand = &quot;tar cvf $sFilename [directory]/*&quot;;
&nbsp;
Whatever command you use, this script appends .gz to the filename after the command is executed.  */</span>
<span style="color: #000088;">$sBackupCommand</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;[a backup command]&quot;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">// --- END OF SCRIPT PARAMETERS ---</span>
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">// Edit below at your own risk.  :)</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// Do the backup.</span>
<span style="color: #000088;">$sResult</span> <span style="color: #339933;">=</span> <span style="color: #990000;">passthru</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sBackupCommand</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;; gzip $sFilename&quot;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$sFilename</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;.gz&quot;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">// Create the message.</span>
<span style="color: #000088;">$sMessage</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Compressed database backup file $sFilename attached.&quot;</span>;
<span style="color: #000088;">$sMimeBoundary</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&lt;&lt;&lt;:&quot;</span> <span style="color: #339933;">.</span> <span style="color: #990000;">md5</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">time</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000088;">$sData</span> <span style="color: #339933;">=</span> <span style="color: #990000;">chunk_split</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">base64_encode</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">,</span> <span style="color: #990000;">file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sFilename</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #000088;">$sHeaders</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;From: $sEmailAddress<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
		<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;MIME-Version: 1.0<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
		<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;Content-type: multipart/mixed;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
		<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot; boundary=<span style="color: #000099; font-weight: bold;">\&quot;</span>$sMimeBoundary<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
&nbsp;
<span style="color: #000088;">$sContent</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;This is a multi-part message in MIME format.<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
		<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;--$sMimeBoundary<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
		<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;Content-Type: text/plain; charset=<span style="color: #000099; font-weight: bold;">\&quot;</span>iso-8859-1<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
		<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;Content-Transfer-Encoding: 7bit<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
		<span style="color: #339933;">.</span> <span style="color: #000088;">$sMessage</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
		<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;--$sMimeBoundary<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
		<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;Content-Disposition: attachment;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
		<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;Content-Type: Application/Octet-Stream; name=<span style="color: #000099; font-weight: bold;">\&quot;</span>$sFilename<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
		<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;Content-Transfer-Encoding: base64<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span><span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
		<span style="color: #339933;">.</span> <span style="color: #000088;">$sData</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
		<span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;--$sMimeBoundary<span style="color: #000099; font-weight: bold;">\r</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">// Send the message.</span>
<span style="color: #990000;">mail</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sEmailAddress</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sEmailSubject</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sContent</span><span style="color: #339933;">,</span> <span style="color: #000088;">$sHeaders</span><span style="color: #009900;">&#41;</span>;
&nbsp;
<span style="color: #666666; font-style: italic;">// Delete the file - we don't need it any more.</span>
<span style="color: #990000;">unlink</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sFilename</span><span style="color: #009900;">&#41;</span>;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://djs-consulting.com/linux/blog/2008/a-handy-php-backup-script/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
	</channel>
</rss>
