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
/usr/bin/mysqldump --single-transaction --no-create-db
--no-create-info databasename salestable1
--where="acctstarttime
LIKE '2016-12-28%'" > /dbbackup/`date +%F`-salestable1.sql
Here the problem is i have to manually change the date part LIKE '2016-12-28%'
inside mysql execute command manually.
How to construct the current script so that it can backup the table with records created on particular day withouthaving to change date manually ?
solution for my case
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}%'" > \
/backup/freeradius/radacct-`date +%F -d '-1 day'`.sql