snipt

Ctrl+h for KB shortcuts

Bash

Export PostgreSQL schema only (no data) and discard ownership

pg_dump --schema-only --no-owner -h {host} -U {user} -f {filename.sql} {database-name}
https://snipt.net/embed/e552972d1b42c3d6f5e1a796a7d3355c/
https://snipt.net/raw/e552972d1b42c3d6f5e1a796a7d3355c/
e552972d1b42c3d6f5e1a796a7d3355c
bash
Bash
2
2016-09-27T13:31:53
True
False
False
Sep 01, 2016 at 04:22 PM
/api/public/snipt/147682/
export-postgresql-schema-only-no-data-and-discard-ownership
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a>pg_dump --schema-only --no-owner -h <span class="o">{</span>host<span class="o">}</span> -U <span class="o">{</span>user<span class="o">}</span> -f <span class="o">{</span>filename.sql<span class="o">}</span> <span class="o">{</span>database-name<span class="o">}</span> </span></pre></div> </td></tr></table>
backup, postgresql

Bash

Compact tar.bz2 and on destination

1
2
3
#This is useful when you don't have much space on server, and need backup or copy
#So, you can backup direct to destination.
tar -cf - /home/dir_backup |bzip2 -9vv | ssh root@ipremotehost "cat > /backups/dir_backup.tar.bz2"
https://snipt.net/embed/ff3556c4d1185c97e7eacbd696ca6a35/
https://snipt.net/raw/ff3556c4d1185c97e7eacbd696ca6a35/
ff3556c4d1185c97e7eacbd696ca6a35
bash
Bash
4
2016-09-27T12:40:56
True
False
False
Sep 29, 2012 at 03:39 PM
/api/public/snipt/47820/
compact-tarbz2-and-on-destination
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="c">#This is useful when you don&#39;t have much space on server, and need backup or copy</span> </span><span id="L-2"><a name="L-2"></a><span class="c">#So, you can backup direct to destination.</span> </span><span id="L-3"><a name="L-3"></a>tar -cf - /home/dir_backup <span class="p">|</span>bzip2 -9vv <span class="p">|</span> ssh root@ipremotehost <span class="s2">&quot;cat &gt; /backups/dir_backup.tar.bz2&quot;</span> </span></pre></div> </td></tr></table>
backup, bz2, bzip2, ssh, tar, tar.bz2
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.