February 8, 2012

Btw xtrabackup is not only backup..

It is obvious thing for me, but I just figured out it may be not common understanding. Xtrabackup is also can be used (not only can, but we actually use it this way) to clone one slave to another, or just setup new slave from the master. And it is done in almost non-blocking way ( true for InnoDB setups) for cloned server. Here is command

innobackupex-1.5.1 --stream=tar /tmp/ --slave-info | ssh user@DESTSERVER "tar xfi - -C /DESTDIR"

When it finished on destination server you run

innobackupex-1.5.1 --apply-log --use-memory=2G  /DESTDIR

And you have ready database directory, just copy my.cnf from original server and start mysqld.

About Vadim Tkachenko

Vadim leads Percona's development group, which produces the Percona Server and Percona XtraBackup. He is an expert in solid-state storage, and has helped many hardware and software providers succeed in the MySQL market.

Comments

  1. Bruce Bristol says:

    Remember to change the slave’s ‘server_id’ variable if it’s in your my.cnf copied from the original server.

  2. anonymous says:

    wow

  3. John Sheppard says:

    I understand Xtrabackup is InnoDB only. Since 2001 I’ve been using
    Dave Brown’s perl script mysql backup. I
    should very much appreciate knowing what better options are available
    now ?

  4. Todd says:

    Hi, I just tried the above I had to add a few things like user and password. Now I get this error:

    100213 09:52:19 innobackupex-1.5.1: Starting ibbackup with command: xtrabackup –backup –suspend-at-end –log-stream –target-dir=./
    innobackupex-1.5.1: Waiting for ibbackup (pid=7630) to suspend
    innobackupex-1.5.1: Suspend file ‘/var/lib/mysql/xtrabackup_suspended’

    xtrabackup: suspend-at-end is enabled.
    xtrabackup: uses posix_fadvise().
    xtrabackup: cd to /var/lib/mysql
    xtrabackup: Target instance is assumed as followings.
    xtrabackup: innodb_data_home_dir = ./
    xtrabackup: innodb_data_file_path = ibdata1:10M:autoextend
    xtrabackup: innodb_log_group_home_dir = ./
    xtrabackup: innodb_log_files_in_group = 2
    xtrabackup: innodb_log_file_size = 5242880
    xtrabackup: use O_DIRECT
    100213 9:52:19 InnoDB: Operating system error number 13 in a file operation.
    InnoDB: The error means mysqld does not have the access rights to
    InnoDB: the directory.
    InnoDB: File name ./ibdata1
    InnoDB: File operation call: ‘open’.
    InnoDB: Error in opening ./ibdata1
    100213 9:52:19 InnoDB: Operating system error number 13 in a file operation.
    InnoDB: The error means mysqld does not have the access rights to
    InnoDB: the directory.
    xtrabackup: Could not open or create data files.
    xtrabackup: If you tried to add new data files, and it failed here,
    xtrabackup: you should now edit innodb_data_file_path in my.cnf back
    xtrabackup: to what it was, and remove the new ibdata files InnoDB created
    xtrabackup: in this failed attempt. InnoDB only wrote those files full of
    xtrabackup: zeros, but did not yet use them in any way. But be careful: do not
    xtrabackup: remove old data files which contain your precious data!
    innobackupex-1.5.1: Error: ibbackup child process has died at /usr/bin/innobackupex-1.5.1 line 464.

    I don’t quiet understand – what files do I not have permission to write to and has my database been destroyed?

Speak Your Mind

*