snipt

Ctrl+h for KB shortcuts

Bash

quick backup

1
2
3
4
5
6
DB_BASE=db_
for i in {1..255}
do
touch $DB_BASE$(printf "%x" $i).backup$NOW.sql.gz
mysqldump -u $DBUSER -p$DBPWD $DB_BASE$(printf "%x" $i) | gzip -9 > $DB_BASE$(printf "%x" $i).backup$NOW.sql.gz
done
https://snippets.siftie.com/embed/26ddf3dea0bfdd14172d2d5ab89f6a35/
/raw/26ddf3dea0bfdd14172d2d5ab89f6a35/
26ddf3dea0bfdd14172d2d5ab89f6a35
bash
Bash
6
2019-03-19T16:50:49
True
False
False
/api/public/snipt/10589/
quick-backup
<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> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span id="L-1"><a name="L-1"></a><span class="nv">DB_BASE</span><span class="o">=</span>db_ </span><span id="L-2"><a name="L-2"></a><span class="k">for</span> i in <span class="o">{</span>1..255<span class="o">}</span> </span><span id="L-3"><a name="L-3"></a><span class="k">do</span> </span><span id="L-4"><a name="L-4"></a>touch <span class="nv">$DB_BASE</span><span class="k">$(</span><span class="nb">printf</span> <span class="s2">&quot;%x&quot;</span> <span class="nv">$i</span><span class="k">)</span>.backup<span class="nv">$NOW</span>.sql.gz </span><span id="L-5"><a name="L-5"></a>mysqldump -u <span class="nv">$DBUSER</span> -p<span class="nv">$DBPWD</span> <span class="nv">$DB_BASE</span><span class="k">$(</span><span class="nb">printf</span> <span class="s2">&quot;%x&quot;</span> <span class="nv">$i</span><span class="k">)</span> <span class="p">|</span> gzip -9 &gt; <span class="nv">$DB_BASE</span><span class="k">$(</span><span class="nb">printf</span> <span class="s2">&quot;%x&quot;</span> <span class="nv">$i</span><span class="k">)</span>.backup<span class="nv">$NOW</span>.sql.gz </span><span id="L-6"><a name="L-6"></a><span class="k">done</span> </span></pre></div> </td></tr></table>
mysql