Portal Home > Knowledgebase > Articles Database > mysqldump with certain columns between certain date time (dynamic)


mysqldump with certain columns between certain date time (dynamic)




Posted by CymraegWalesHosting, 02-10-2013, 10:13 AM
I am looking at using the mysqldump command in ssh as a cron where it will dump a file to a specific file. I'm looking for some help with the code. Lets say our database is called 'access' and a table called 'connections' I would like to export all the data from the table 'connections' only between yesterdays date at 06:00:00 to today at 05:59:59. However i only want it to export particular columns (id, date/time, ip). This be be each day. Obviously the cron would run everyday. The bit i require help with is the mysqldump command. So to recap. Data only from the connections table Export data that is only from yesterday at 06:00:00 to today at 05:59:59 based date/time column) Export data only from columns id, date/time, ip save the file name as connection-dump-(date/time of the dump) Support is really appreciated. Thanks

Posted by luki, 02-10-2013, 02:10 PM
Try something like this: mysqldump access connections --where 'date >= (CURDATE() - INTERVAL 1 DAY + INTERVAL 6 HOUR) AND date < (CURDATE() + INTERVAL 6 HOUR)'

Posted by CymraegWalesHosting, 02-10-2013, 03:19 PM
Thanks for this. However this works well for future reference. Cheers,



Was this answer helpful?

Add to Favourites Add to Favourites    Print this Article Print this Article

Also Read
ResellerZoom down? (Views: 684)

Language: