aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/postgresql/index.rhtml64
1 files changed, 27 insertions, 37 deletions
diff --git a/docs/postgresql/index.rhtml b/docs/postgresql/index.rhtml
index d0b6f13..ebe778b 100644
--- a/docs/postgresql/index.rhtml
+++ b/docs/postgresql/index.rhtml
@@ -1,5 +1,14 @@
<h1>PostgreSQL</h1>
-<h2>SQL Dump</h2>
+
+<h2>Indice</h2>
+<ol>
+ <li><a href="#sql_dump">SQL Dump</a></li>
+ <li><a href="#ripristinare_il_dump">Ripristinare il dump</a></li>
+ <li><a href="#usare_pg_dumpall">Usare <code>pg_dumpall</code></a></li>
+ <li><a href="#gestire_grandi_database">Gestire grandi database</a></li>
+</ol>
+
+<h2 id="sql_dump">SQL Dump</h2>
<p class="hyphens">L'idea dietro a questo metodo di dump &egrave; quello di generare un file con comandi SQL che,
quando eseguiti dal server, ricrea il database nello stesso stato come quando &egrave; stato
eseguito il dump. PostgreSQL fornisce uno strumento che si chiama <code>pg_dump</code> che serve
@@ -35,7 +44,7 @@ pg_dump dbname > dumpfile
quelle operazioni necessitano di un lock esclusivo, come le pi&ugrave; diffuse varianti di
<code>ALTER TABLE</code>.</p>
-<h2>Ripristinare il dump</h2>
+<h2 id="ripristinare_il_dump">Ripristinare il dump</h2>
<p class="hyphens">Il file creati con <code>pg_dump</code> sono pensati per essere letti dal programma
<code>psql</code>. Il comando generico per ripristinare un dump &egrave; il seguente:
@@ -79,7 +88,7 @@ psql dbname < dumpfile
da <code>pg_dump</code>. Come risultato, quando si esegue il ripristino, se si sta usando un <i>template1</i>
personalizzato, si deve creare un database vuoto da <i>template0</i>, come nell'esempio precedente.</p>
-<h2>Usare <code>pg_dumpall</code></h2>
+<h2 id="usare_pg_dumpall">Usare <code>pg_dumpall</code></h2>
<p class="hyphens"><code>pg_dump</code> effettua il dump di un singolo database alla volta, non effettua il dump delle
informazioni su ruoli e tablespace. Per effettuare il dump di un intero cluster di database, esiste il programma
<code>pg_dumpall</code>. L'utilizzo base del comando &egrave; il seguente:</p>
@@ -90,53 +99,34 @@ psql dbname < dumpfile
<pre class="bordered">psql -f dumpfile postgres</pre>
-<h2>Gestire grandi database</h2>
-<p>Alcuni sistemi operativi hanno i limiti massimi sulla dimensione dei file che potrebbero causare
+<h2 id="gestire_grandi_database">Gestire grandi database</h2>
+<p class="hyphens">Alcuni sistemi operativi hanno i limiti massimi sulla dimensione dei file che potrebbero causare
problemi creando grandi file con <code>pg_dump</code>. Fortunatamente, <code>pg_dump</code> pu&ograve;
scrivere sullo standard output, cos&igrave; lo si pu&ograve; usare insieme agli strumenti standard di Unix
per aggirare questo potenziale problema. Ci sono molteplici metodi:</p>
-<p>Usare dei dump compressi:</p>
-<p>Si pu&ograve; usare qualsiasi programma di compressione che si preferisce, ad esempio
+<p class="hyphens">Usare dei dump compressi:</p>
+<p class="hyphens">Si pu&ograve; usare qualsiasi programma di compressione che si preferisce, ad esempio
con <code>gzip</code>
<pre class="bordered">
pg_dump dbname | gzip > filename.gz
</pre>
-<p>Si ripristina con:</p>
+<p class="hyphens">Si ripristina con:</p>
<pre class="bordered">
gunzip -c filename.gz | psql dbname
</pre>
-<p>Oppure</p>
+<p class="hyphens">Oppure:</p>
<pre class="bordered">
cat filename.gz | gunzip | psql dbname
</pre>
-
-<pre style="background: cyan">
-
-Use split. The split command allows you to split the output into smaller files that are acceptable in size to the underlying file system. For example, to make chunks of 1 megabyte:
-
+<p class="hyphens">Oltre alla creazione di un file gz, &egrave; possibile spezzare il dump in pi&ugrave; file, usando
+ il comando <code>split</code>. Questo comando permette di spezzare l'output di <code>pg_dump</code> in file
+ pi&ugrave; piccoli che possono essere salvati da file system che non sono in grado di gestire file di enormi
+ dimensioni. Per esempio, per creare porzioni di file da 1 megabyte, eseguire:</p>
+<pre class="bordered">
pg_dump dbname | split -b 1m - filename
-
-Reload with:
-
+</pre>
+<p class="hyphens">Per poi ripristinarlo in questo modo:</p>
+<pre class="bordered">
cat filename* | psql dbname
-
-Use pg_dump's custom dump format. If PostgreSQL was built on a system with the zlib compression library installed, the custom dump format will compress data as it writes it to the output file. This will produce dump file sizes similar to using gzip, but it has the added advantage that tables can be restored selectively. The following command dumps a database using the custom dump format:
-
-pg_dump -Fc dbname > filename
-
-A custom-format dump is not a script for psql, but instead must be restored with pg_restore, for example:
-
-pg_restore -d dbname filename
-
-See the pg_dump and pg_restore reference pages for details.
-
-For very large databases, you might need to combine split with one of the other two approaches.
-
-Use pg_dump's parallel dump feature. To speed up the dump of a large database, you can use pg_dump's parallel mode. This will dump multiple tables at the same time. You can control the degree of parallelism with the -j parameter. Parallel dumps are only supported for the "directory" archive format.
-
-pg_dump -j num -F d -f out.dir dbname
-
-You can use pg_restore -j to restore a dump in parallel. This will work for any archive of either the "custom" or the "directory" archive mode, whether or not it has been created with pg_dump -j.
-
-</pre> \ No newline at end of file
+</pre>