Bash script to run mysqldump to take regular backup of a single table with rows create 1 day before
<p>Below is the BASH(Version 4.1.2) script i have placed on cronjob which runs daily at 23:59 to backup a table with records created on that particur day </p>

<pre><code>/usr/bin/mysqldump --single-transaction --no-create-db 
--no-create-info databasename salestable1 
--where="acctstarttime 
LIKE '2016-12-28%'" &gt;  /dbbackup/`date +%F`-salestable1.sql
</code></pre>

<p>Here the problem is i have to manually change the date part <code>LIKE '2016-12-28%'</code> inside <em>mysql execute command</em> manually. </p>

<p>How to construct the current script so that it can backup the table with records created on particular day withouthaving to change date manually ?</p>

<h2>solution for my case</h2>

<pre><code>sys_date=`date +%F -d '-1 day'`
/usr/bin/mysqldump --single-transaction --no-create-db   \ 
--no-create-info ctradius radacct     \
--where="acctstarttime LIKE '${sys_date}%'" &gt;      \
/backup/freeradius/radacct-`date +%F -d '-1 day'`.sql
</code></pre>