patternsqlMinor
Is it possible to get the last restore date of a MySQL instance?
Viewed 0 times
lastthedateinstancepossiblegetmysqlrestore
Problem
Is it possible to get the last restore date of a MySQL database?
I am going to restore the database from a
I tried to query the
I am going to restore the database from a
.sql dump file, but I don't know how to get from the database, the last time when a restore happened.I tried to query the
information_schema.tables table in order to check the creation_time of each table, but they seem to be not updated after the restore.Solution
I've just tested your solution about the "CREATE_TIME" field in information_schema and I think it's the good one, look :
I did a mysqldump of MFO DB:
Then loaded it:
Now the CREATE_TIME is today:
Best regards.
Max.
[root@localhost] [MFO] mysql> select * from information_schema.tables where table_name = "myisammfo"\G
*************************** 1. row ***************************
TABLE_CATALOG: NULL
TABLE_SCHEMA: MFO
TABLE_NAME: myisammfo
TABLE_TYPE: BASE TABLE
ENGINE: MyISAM
VERSION: 10
ROW_FORMAT: Fixed
TABLE_ROWS: 2
AVG_ROW_LENGTH: 7
DATA_LENGTH: 14
MAX_DATA_LENGTH: 1970324836974591
INDEX_LENGTH: 1024
DATA_FREE: 0
AUTO_INCREMENT: NULL
CREATE_TIME: 2013-03-05 15:15:22
UPDATE_TIME: 2013-03-05 15:17:58
CHECK_TIME: 2013-03-05 15:18:28
TABLE_COLLATION: latin1_swedish_ci
CHECKSUM: NULL
CREATE_OPTIONS:
TABLE_COMMENT:
1 row in set (0.01 sec)I did a mysqldump of MFO DB:
predator:~# mysqldump -uroot -p --databases MFO >/tmp/MFO.SQLThen loaded it:
predator:~# mysql -uroot -p </tmp/MFO.SQLNow the CREATE_TIME is today:
predator:~# mysql -uroot -p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 86261
Server version: 5.0.51a-24+lenny5 (Debian)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
[root@localhost] [(none)] mysql> select * from information_schema.tables where table_name = "myisammfo"\G
*************************** 1. row ***************************
TABLE_CATALOG: NULL
TABLE_SCHEMA: MFO
TABLE_NAME: myisammfo
TABLE_TYPE: BASE TABLE
ENGINE: MyISAM
VERSION: 10
ROW_FORMAT: Fixed
TABLE_ROWS: 2
AVG_ROW_LENGTH: 7
DATA_LENGTH: 14
MAX_DATA_LENGTH: 1970324836974591
INDEX_LENGTH: 1024
DATA_FREE: 0
AUTO_INCREMENT: NULL
CREATE_TIME: 2013-10-02 16:45:56
UPDATE_TIME: 2013-10-02 16:45:56
CHECK_TIME: NULL
TABLE_COLLATION: latin1_swedish_ci
CHECKSUM: NULL
CREATE_OPTIONS:
TABLE_COMMENT:
1 row in set (0.00 sec)Best regards.
Max.
Code Snippets
[root@localhost] [MFO] mysql> select * from information_schema.tables where table_name = "myisammfo"\G
*************************** 1. row ***************************
TABLE_CATALOG: NULL
TABLE_SCHEMA: MFO
TABLE_NAME: myisammfo
TABLE_TYPE: BASE TABLE
ENGINE: MyISAM
VERSION: 10
ROW_FORMAT: Fixed
TABLE_ROWS: 2
AVG_ROW_LENGTH: 7
DATA_LENGTH: 14
MAX_DATA_LENGTH: 1970324836974591
INDEX_LENGTH: 1024
DATA_FREE: 0
AUTO_INCREMENT: NULL
CREATE_TIME: 2013-03-05 15:15:22
UPDATE_TIME: 2013-03-05 15:17:58
CHECK_TIME: 2013-03-05 15:18:28
TABLE_COLLATION: latin1_swedish_ci
CHECKSUM: NULL
CREATE_OPTIONS:
TABLE_COMMENT:
1 row in set (0.01 sec)predator:~# mysqldump -uroot -p --databases MFO >/tmp/MFO.SQLpredator:~# mysql -uroot -p </tmp/MFO.SQLpredator:~# mysql -uroot -p
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 86261
Server version: 5.0.51a-24+lenny5 (Debian)
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
[root@localhost] [(none)] mysql> select * from information_schema.tables where table_name = "myisammfo"\G
*************************** 1. row ***************************
TABLE_CATALOG: NULL
TABLE_SCHEMA: MFO
TABLE_NAME: myisammfo
TABLE_TYPE: BASE TABLE
ENGINE: MyISAM
VERSION: 10
ROW_FORMAT: Fixed
TABLE_ROWS: 2
AVG_ROW_LENGTH: 7
DATA_LENGTH: 14
MAX_DATA_LENGTH: 1970324836974591
INDEX_LENGTH: 1024
DATA_FREE: 0
AUTO_INCREMENT: NULL
CREATE_TIME: 2013-10-02 16:45:56
UPDATE_TIME: 2013-10-02 16:45:56
CHECK_TIME: NULL
TABLE_COLLATION: latin1_swedish_ci
CHECKSUM: NULL
CREATE_OPTIONS:
TABLE_COMMENT:
1 row in set (0.00 sec)Context
StackExchange Database Administrators Q#50870, answer score: 4
Revisions (0)
No revisions yet.