<?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>LuAuF &#187; PostgreSQL</title>
	<atom:link href="http://luauf.com/category/bases-de-datos/postgresql/feed/" rel="self" type="application/rss+xml" />
	<link>http://luauf.com</link>
	<description></description>
	<lastBuildDate>Tue, 11 May 2010 01:27:59 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Postgres backup desde Java</title>
		<link>http://luauf.com/2008/07/06/postgres-backup-desde-java/</link>
		<comments>http://luauf.com/2008/07/06/postgres-backup-desde-java/#comments</comments>
		<pubDate>Sun, 06 Jul 2008 17:25:33 +0000</pubDate>
		<dc:creator>Luciano</dc:creator>
				<category><![CDATA[Bases de Datos]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Programación]]></category>
		<category><![CDATA[Postgres]]></category>

		<guid isPermaLink="false">http://luauf.com/?p=488</guid>
		<description><![CDATA[Mientras realizaba una recorrida por los blogs que suelo frecuentar, me encontré con una publicación interesante de eOS's BLOG, donde desde un pequeño proceso en Java realiza un backup de Postgres. Si bien el proceso es sencillo, del mismo podrás sacar algunas cosas interesante como: Utilizar el comando pg_dump para exportar una base de datos [...]]]></description>
			<content:encoded><![CDATA[<p>Mientras realizaba una recorrida por los blogs que suelo frecuentar, me encontré con una publicación interesante de <a href="http://eos87.blogspot.com/">eOS's BLOG</a>, donde desde un pequeño proceso en Java realiza un backup de Postgres.</p>
<p>Si bien el proceso es sencillo, del mismo podrás sacar algunas cosas interesante como:</p>
<ul>
<li>Utilizar el comando pg_dump para exportar una base de datos PostgreSQL (algo así como el mysqldump de MySQL)</li>
<li>Ejecutar un comando desde Java (algo así como el system de C)</li>
<li>Setear variables en el entorno actual de ejecución</li>
</ul>
<p><span id="more-488"></span></p>
<p>El código habla por si solo:<br />
<code></p>
<div class="syntax_hilite">
<div id="java-2">
<div class="java"><span style="color: #000000; font-weight: bold;">try</span> <span style="color: #66cc66;">&#123;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> path = <span style="color: #ff0000;">"path del archivo de backup"</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3ARuntime+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Runtime</span></a> r = <a href="http://www.google.com/search?q=allinurl%3ARuntime+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Runtime</span></a>.<span style="color: #006600;">getRuntime</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> user = <span style="color: #ff0000;">"postgres"</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> dbase = <span style="color: #ff0000;">"base_datos"</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3AString+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">String</span></a> password = <span style="color: #ff0000;">"tu_contraseña"</span>;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; <a href="http://www.google.com/search?q=allinurl%3AProcess+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Process</span></a> p;<br />
&nbsp; &nbsp; &nbsp; &nbsp; ProcessBuilder pb;</p>
<p>&nbsp; &nbsp; &nbsp; &nbsp; r = <a href="http://www.google.com/search?q=allinurl%3ARuntime+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Runtime</span></a>.<span style="color: #006600;">getRuntime</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; pb = <span style="color: #000000; font-weight: bold;">new</span> ProcessBuilder<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"pg_dump"</span>, <span style="color: #ff0000;">"-v"</span>, <span style="color: #ff0000;">"-D"</span>, <span style="color: #ff0000;">"-f"</span>, path, <span style="color: #ff0000;">"-U"</span>, user, dbase<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; pb.<span style="color: #006600;">environment</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>.<span style="color: #006600;">put</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">"PGPASSWORD"</span>, password<span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; pb.<span style="color: #006600;">redirectErrorStream</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;<br />
&nbsp; &nbsp; &nbsp; &nbsp; p = pb.<span style="color: #006600;">start</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;&nbsp; &nbsp; &nbsp; &nbsp; </p>
<p>&nbsp; &nbsp; <span style="color: #66cc66;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #66cc66;">&#40;</span><a href="http://www.google.com/search?q=allinurl%3AException+java.sun.com&amp;bntl=1"><span style="color: #aaaadd; font-weight: bold;">Exception</span></a> e<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span></p>
<p><span style="color: #66cc66;">&#125;</span></div>
</div>
</div>
<p>
</code></p>
<p>Via: <a href="http://eos87.blogspot.com/2008/06/backup-de-postgres-desde-java.html">eOS's BLOG</a></p>
]]></content:encoded>
			<wfw:commentRss>http://luauf.com/2008/07/06/postgres-backup-desde-java/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Instalar PostgreSQL en Ubuntu</title>
		<link>http://luauf.com/2008/05/28/instalar-postgresql-en-ubuntu/</link>
		<comments>http://luauf.com/2008/05/28/instalar-postgresql-en-ubuntu/#comments</comments>
		<pubDate>Wed, 28 May 2008 22:37:29 +0000</pubDate>
		<dc:creator>Luciano</dc:creator>
				<category><![CDATA[Bases de Datos]]></category>
		<category><![CDATA[PostgreSQL]]></category>
		<category><![CDATA[Ubuntu]]></category>

		<guid isPermaLink="false">http://luauf.com/?p=334</guid>
		<description><![CDATA[Instalar el servidor de base de datos PostgreSQL en Linux, es tan fácil como instalar cualquier otro programa en Linux. De todas formas, en esta publicación repasaremos un poco los pasos a seguir, para instalar PostgreSQL 8-3 en Ubuntu Hardy Heron. Abrir el Gestor de Paquetes Synaptic (si lo deseas hacer por consola, puedes hacerlo [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">Instalar el servidor de base de datos PostgreSQL en Linux, es tan fácil como <a href="http://luauf.com/2008/04/20/instalando-programas-linux-vs-windows/" target="_self">instalar cualquier otro programa en Linux</a>. De todas formas, en esta publicación repasaremos un poco los pasos a seguir, para instalar PostgreSQL 8-3 en Ubuntu Hardy Heron.</p>
<p style="text-align: center;"><a href="http://luauf.com/wp-content/uploads/2008/05/logo_postgres-791620.gif"><img class="size-medium wp-image-335 aligncenter" title="logo_postgres-791620" src="http://luauf.com/wp-content/uploads/2008/05/logo_postgres-791620-300x237.gif" alt="" width="300" height="237" /></a></p>
<p><span id="more-334"></span></p>
<ul>
<li>Abrir el Gestor de Paquetes Synaptic (si lo deseas hacer por consola, puedes hacerlo con apt-get)</li>
</ul>
<p style="text-align: center;"><a href="http://luauf.com/wp-content/uploads/2008/05/postgresql.jpg"><img class="alignnone size-medium wp-image-338 aligncenter" title="postgresql" src="http://luauf.com/wp-content/uploads/2008/05/postgresql-300x210.jpg" alt="" width="300" height="210" /></a></p>
<ul>
<li>Buscar el paquete postgresql, seleccionarlo y aceptar los otros paquetes requeridos (libpq5, postgresql-client, postgresql-client-common y postgresql-common)</li>
</ul>
<p style="text-align: center;"><a href="http://luauf.com/wp-content/uploads/2008/05/descarga.jpg"><img class="alignnone size-medium wp-image-339" title="descarga" src="http://luauf.com/wp-content/uploads/2008/05/descarga-300x153.jpg" alt="" width="300" height="153" /></a></p>
<ul>
<li>Aplicar los cambios y esperar la descarga de unos 20Mb aproximadamente.</li>
</ul>
<p style="text-align: left;">Luego, para controlar el servicio, lo haces como cualquier otro servicio:</p>
<p><code></p>
<div class="syntax_hilite">
<div id="code-5">
<div class="code">$ sudo /etc/init.<span style="">d</span>/postgresql-<span style="color:#800000;">8</span>.<span style="color:#800000;">3</span> stop<br />
* Stopping PostgreSQL <span style="color:#800000;">8</span>.<span style="color:#800000;">3</span> database server&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">&#91;</span> OK <span style="color:#006600; font-weight:bold;">&#93;</span><br />
$ sudo /etc/init.<span style="">d</span>/postgresql-<span style="color:#800000;">8</span>.<span style="color:#800000;">3</span> start<br />
* Starting PostgreSQL <span style="color:#800000;">8</span>.<span style="color:#800000;">3</span> database server&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color:#006600; font-weight:bold;">&#91;</span> OK <span style="color:#006600; font-weight:bold;">&#93;</span><br />
$</div>
</div>
</div>
<p>
</code></p>
<p style="text-align: left;">Finalmente, si deseas cambiar la contraseña del usuario postgres (el equivalente al usuario root), puedes seguir los siguientes pasos (Vía: <a href="http://johansoft.blogspot.com/2007/09/cambiar-contrasea-de-usuario-postgres.html" target="_blank">Cambiar contraseña de usuario 'postgres' en Ubuntu</a>)</p>
<p style="text-align: left;">Por características de seguridad e<span style="font-size: 100%;">l paquete de instalacion de ubuntu no revela cual es la contraseña asignada al usuario 'postgres', para asignar una contraseña conocida, debes abrir el cliente plsql con el usuario posgresql y realizar el ALTER USER para cambiar la contraseña:<br />
</span></p>
<p><code></p>
<div class="syntax_hilite">
<div id="code-6">
<div class="code">$ sudo su postgres<br />
# psql<br />
Bienvenido a psql <span style="color:#800000;">8</span>.<span style="color:#800000;">3</span>.<span style="color:#800000;">1</span>, la terminal interactiva de PostgreSQL.</p>
<p><span style="">Digite</span>:&nbsp; \copyright para ver los términos de distribución<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\h para ayuda de órdenes SQL<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\? para ayuda de órdenes psql<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\g o punto y coma <span style="color:#006600; font-weight:bold;">&#40;</span>«;»<span style="color:#006600; font-weight:bold;">&#41;</span> para ejecutar la consulta<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\q para salir</p>
<p>postgres=# alter user postgres with password <span style="color:#CC0000;">'mi_clave_secreta'</span>;<br />
ALTER ROLE<br />
postgres=# \q<br />
# exit<br />
$ psql -hlocalhost -Upostgres -W<br />
Contraseña para usuario postgres:</p>
<p>Digite:&nbsp; \copyright para ver los términos de distribución<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\h para ayuda de órdenes SQL<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\? para ayuda de órdenes psql<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\g o punto y coma <span style="color:#006600; font-weight:bold;">&#40;</span>«;»<span style="color:#006600; font-weight:bold;">&#41;</span> para ejecutar la consulta<br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;\q para salir</div>
</div>
</div>
<p>
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://luauf.com/2008/05/28/instalar-postgresql-en-ubuntu/feed/</wfw:commentRss>
		<slash:comments>15</slash:comments>
		</item>
	</channel>
</rss>
