I have mysql running in a docker container in my centos 6.6. server. With my docker container called "mysql", I create this useful script that copies my "PATCH_RECORD" table in my niis database daily and it works fine.
docker exec mysql mysql -u root -pmypassword niis -e "CREATE TABLE patching_`date +%d_%h_%Y` SELECT * FROM PATCH_RECORD; "
I then have a cron job that runs the script daily so I have daily backups of my PATCH_RECORD table.
Now I need to drop the backed up tables older than 5 days by running another cron job so i don't keep tables more than 5 days old. I am trying to get the exact syntax for this but can't seem to catch it. Something like this:
docker exec mysql mysql -u root -pmypassword niis -e "DROP TABLE patching_`date +%d_%h_%Y -5d`;
The bash interpreter is interpreting -5d as text so it is resulting in a syntax error. I tried various combinations of -v, or -d or putting "-5d" with no luck.
Any help with syntax will be appreciated.