I have a set of tables in my database that I should take a dump (: D). My problem is that I want to take some data from some tables that apply only to certain days and would like to keep the remaining tables in tact.
The query I came up with was something like:
mysqldump -h<hostname> -u<username> -p <databasename> <table1> <table2> <table3> <table4> --where 'created > DATE_SUB(now(), INTERVAL 7 DAY)', <table5> --where 'created > DATE_SUB(now(), INTERVAL 7 DAY) --single-transaction --no-create-info | gzip > $(date +%Y-%m-%d-%H)-dump.sql.gz
The problem with the above code is that table1, table2 and table3 will try to take the where clause in table4. I do not want this reason to spit out the error that created the field in these tables.
I tried putting a comma (,) after the table names in the same way as after the where clause, but this will not work.
At this moment I was pretty stuck and no longer want an alternative to expect to create two different sql dump files that I would not want to do.
source share