7.4 Example: Restoring a Database at its Original Location

The log files have been applied to the backup (in /backups/2004-02-03_13-27-09):

$ ls -l /backups/2010-12-08_16-18-22
total 530468
-rw-r--r-- 1 pekka pekka       347 2010-12-08 16:18 backup-my.cnf
-rw-r--r-- 1 pekka pekka        18 2010-12-08 16:19 ibbackup_binlog_info
-rw-r--r-- 1 pekka pekka       158 2010-12-08 16:19 ibbackup_export_variables.txt
-rw-r----- 1 pekka pekka      1024 2010-12-08 16:19 ibbackup_logfile
-rw-r----- 1 pekka pekka  10485760 2010-12-08 16:24 ibdata1
-rw-r----- 1 pekka pekka  20971520 2010-12-08 16:24 ibdata2
-rw-r----- 1 pekka pekka 480247808 2010-12-08 16:24 ibdata3
-rw-r----- 1 pekka pekka  10485760 2010-12-08 16:24 ib_logfile0
-rw-r----- 1 pekka pekka  10485760 2010-12-08 16:23 ib_logfile1
-rw-r----- 1 pekka pekka  10485760 2010-12-08 16:23 ib_logfile2
-rw-r--r-- 1 pekka pekka      3600 2010-12-08 16:23 my.cnf
drwx------ 2 pekka pekka      4096 2010-12-08 16:19 mysql
drwx------ 2 pekka pekka        24 2010-12-08 16:19 test

We copy InnoDB and MyISAM indexes, and .frm files back to their original locations (defined by /home/pekka/.my.cnf file):

$ mysqlbackup --copy-back /home/pekka/.my.cnf /backups/2010-12-08_16-18-22
mysqlbackup: Starting mysqlbackup with following arguments:
mysqlbackup --copy-back /home/pekka/.my.cnf /backups/2010-12-08_16-18-22  
mysqlbackup: IMPORTANT: Please check that copy-back run completes successfully.
            At the end of a successful 'copy-back' run mysqlbackup
            prints "mysqlbackup completed OK!".

mysqlbackup: Starting to copy back files 
mysqlbackup: in '/backups/2010-12-08_16-18-22' directory 
mysqlbackup: back to original data directory '/sqldata/simple'
mysqlbackup: Copying back file '/backups/2010-12-08_16-18-22/ibbackup_binlog_info'
mysqlbackup: Copying back file '/backups/2010-12-08_16-18-22/my.cnf'
mysqlbackup: Copying back directory '/backups/2010-12-08_16-18-22/mysql'
mysqlbackup: Copying back directory '/backups/2010-12-08_16-18-22/test'
mysqlbackup: Starting to copy back InnoDB tables and indexes
mysqlbackup: in '/backups/2010-12-08_16-18-22'
mysqlbackup: back to original InnoDB datadirectory '/sqldata/simple'
mysqlbackup: Copying back file '/backups/2010-12-08_16-18-22/ibdata1'
mysqlbackup: Copying back file '/backups/2010-12-08_16-18-22/ibdata2'
mysqlbackup: Copying back file '/backups/2010-12-08_16-18-22/ibdata3'
mysqlbackup: Starting to copy back InnoDB log files
mysqlbackup: in '/backups/2010-12-08_16-18-22' 
mysqlbackup: back to original InnoDB log directory '/sqldata/simple'
mysqlbackup: Copying back file '/backups/2010-12-08_16-18-22/ib_logfile0'
mysqlbackup: Copying back file '/backups/2010-12-08_16-18-22/ib_logfile1'
mysqlbackup: Copying back file '/backups/2010-12-08_16-18-22/ib_logfile2'
mysqlbackup: Finished copying backup files.


101208 16:48:13 mysqlbackup: mysqlbackup completed OK!

The original database directory is now restored from the backup:

$ ls -l /sqldata/simple
total 531292
-rw-r--r-- 1 pekka pekka       533 2010-12-08 15:47 backup-my.cnf
-rw-r--r-- 1 pekka pekka        18 2010-12-08 16:47 ibbackup_binlog_info
-rw-r----- 1 pekka pekka  10485760 2010-12-08 16:47 ibdata1
-rw-r----- 1 pekka pekka  20971520 2010-12-08 16:47 ibdata2
-rw-r----- 1 pekka pekka 480247808 2010-12-08 16:48 ibdata3
-rw-r----- 1 pekka pekka  10485760 2010-12-08 16:48 ib_logfile0
-rw-r----- 1 pekka pekka  10485760 2010-12-08 16:48 ib_logfile1
-rw-r----- 1 pekka pekka  10485760 2010-12-08 16:48 ib_logfile2
-rw-r--r-- 1 pekka pekka      3600 2010-12-08 16:47 my.cnf
drwx------ 2 pekka pekka      4096 2010-05-17 18:41 mysql
drwx------ 2 pekka pekka    827392 2010-03-22 16:13 test

and we can start a server on it:

$ mysqld
101208 16:48:14 [Warning] Changed limits: max_open_files: 1024  max_connections: 200  table_cache: 407
101208 16:48:14 [Warning] One can only use the --user switch if running as root

101208 16:48:14 [Note] Plugin 'FEDERATED' is disabled.
101208 16:48:15  InnoDB: Started; log sequence number 7 2099896332
101208 16:48:15 [Note] Event Scheduler: Loaded 0 events
101208 16:48:15 [Note] mysqld: ready for connections.