snipt

Ctrl+h for KB shortcuts

Bash

Backup and compress a MySQL DB

mysqldump $DB_NAME -R -q --user=$USER --password=$PASSWORD --lock-tables | gzip > $BACKUPDIR/$BACKUPNAME
https://snipt.net/embed/ded50795e42c5309713131ffdceee243/
/raw/ded50795e42c5309713131ffdceee243/
ded50795e42c5309713131ffdceee243
bash
Bash
2
2019-07-22T18:43:26
True
False
False
/api/public/snipt/6900/
backup-and-compress-a-mysql-db
<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></span><span id="L-1"><a name="L-1"></a>mysqldump <span class="nv">$DB_NAME</span> -R -q --user<span class="o">=</span><span class="nv">$USER</span> --password<span class="o">=</span><span class="nv">$PASSWORD</span> --lock-tables <span class="p">|</span> gzip &gt; <span class="nv">$BACKUPDIR</span>/<span class="nv">$BACKUPNAME</span> </span></pre></div> </td></tr></table>
archive, backup, mysql, shell

Bash

save and restore the list of installed packages

1
2
3
4
5
dpkg --get-selections > selections.txt

dpkg --set-selections < selections.txt
dselect update
apt-get dselect-upgrade
https://snipt.net/embed/dd50187add2d7bd25d692862d3929072/
/raw/dd50187add2d7bd25d692862d3929072/
dd50187add2d7bd25d692862d3929072
bash
Bash
5
2019-07-21T04:32:06
True
False
False
/api/public/snipt/6053/
save-and-restore-the-list-of-installed-packages
<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> <a href="#L-4">4</a> <a href="#L-5">5</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>dpkg --get-selections &gt; selections.txt </span><span id="L-2"><a name="L-2"></a> </span><span id="L-3"><a name="L-3"></a>dpkg --set-selections &lt; selections.txt </span><span id="L-4"><a name="L-4"></a>dselect update </span><span id="L-5"><a name="L-5"></a>apt-get dselect-upgrade </span></pre></div> </td></tr></table>
backup, linux, packages

Text only

create bzr repo branch on jungle disk

bzr branch . j:/code/new-folder --no-tree
bzr bind j:/code/new-folder
https://snipt.net/embed/d04e9d7b70d9023dc84ad3c438b1b798/
/raw/d04e9d7b70d9023dc84ad3c438b1b798/
d04e9d7b70d9023dc84ad3c438b1b798
text
Text only
2
2019-07-23T12:37:17
True
False
False
Feb 23, 2013 at 07:07 PM
/api/public/snipt/5455/
create-bzr-repo-branch-on-jungle-disk
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a>bzr branch . j:/code/new-folder --no-tree </span><span id="L-2"><a name="L-2"></a>bzr bind j:/code/new-folder </span></pre></div> </td></tr></table>
backup, bazaar, bzr, dvcs, svn

Bash

backup all databases mysql

mysqldump --opt --extended-insert --single-transaction --create-options --default-character-set=utf8 --all-databases --user=<user> --password=<password> > all.sql
https://snipt.net/embed/2b620a12190a51ef2778c379b44721d1/
/raw/2b620a12190a51ef2778c379b44721d1/
2b620a12190a51ef2778c379b44721d1
bash
Bash
1
2019-07-20T20:29:17
True
False
False
/api/public/snipt/4914/
backup-all-databases-mysql
<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></span><span id="L-1"><a name="L-1"></a>mysqldump --opt --extended-insert --single-transaction --create-options --default-character-set<span class="o">=</span>utf8 --all-databases --user<span class="o">=</span>&lt;user&gt; --password<span class="o">=</span>&lt;password&gt; &gt; all.sql </span></pre></div> </td></tr></table>
backup, mysql, sysadmin

Bash

mysql dump a database

mysqldump db_name > backup-file.sql
https://snipt.net/embed/0c468b2c1ddf9092199d6afcfba172ab/
/raw/0c468b2c1ddf9092199d6afcfba172ab/
0c468b2c1ddf9092199d6afcfba172ab
bash
Bash
1
2019-07-22T19:26:04
True
False
False
Feb 23, 2013 at 06:59 PM
/api/public/snipt/1116/
mysql-dump-a-database
<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></span><span id="L-1"><a name="L-1"></a>mysqldump db_name &gt; backup-file.sql </span></pre></div> </td></tr></table>
backup, linux, mysql

Bash

tar and zip an entire folder

tar cvzfp site.tgz /home/user/public_html
https://snipt.net/embed/57a47c629711876cecbeb8267cb8a528/
/raw/57a47c629711876cecbeb8267cb8a528/
57a47c629711876cecbeb8267cb8a528
bash
Bash
1
2019-07-22T11:14:02
True
False
False
Feb 23, 2013 at 06:59 PM
/api/public/snipt/1115/
tar-and-zip-an-entire-folder
<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></span><span id="L-1"><a name="L-1"></a>tar cvzfp site.tgz /home/user/public_html </span></pre></div> </td></tr></table>
backup, bash, linux, tar, zip

Bash

mysql dump into file

mysqldump -u USER -p DATABASE > filename.sql
https://snipt.net/embed/4ab6543aeaabfd991684f9a173a932cf/
/raw/4ab6543aeaabfd991684f9a173a932cf/
4ab6543aeaabfd991684f9a173a932cf
bash
Bash
1
2019-07-20T23:57:31
True
False
False
/api/public/snipt/292/
mysql-dump-into-file
<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></span><span id="L-1"><a name="L-1"></a>mysqldump -u USER -p DATABASE &gt; filename.sql </span></pre></div> </td></tr></table>
backup, mysql