Restoring from an innobackupex stream backup

1,691 views
Skip to first unread message

Michael Bravo

unread,
Sep 26, 2011, 2:57:54 AM9/26/11
to percona-d...@googlegroups.com
Hello,

I have a question which probably has a very obvious answer, but it isn't mentioned anywhere I was able to look/search, and with the backup sizes I'm dealing with, it is not really feasible to experiment much :)

Presuming I have a backup.tar.gz resulted from a innobackupex stream mode backup, how exactly do I do a restore from it? (I know how to restore from a non-stream backup directory)

-- 
Michael Bravo

Will Gunty

unread,
Sep 26, 2011, 2:59:51 AM9/26/11
to percona-d...@googlegroups.com
You should be able to untag it, run the preparation, and then move it into place.

I use streams like this to populate or repopulate servers, streaming to the new server and unzipping on the other side.  Then I run prepare and move into place.  Voilla.

-- 
Will Gunty
Sent with Sparrow

--
You received this message because you are subscribed to the Google Groups "Percona Discussion" group.
To view this discussion on the web visit https://groups.google.com/d/msg/percona-discussion/-/kZ4YOJlQJyMJ.
To post to this group, send email to percona-d...@googlegroups.com.
To unsubscribe from this group, send email to percona-discuss...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/percona-discussion?hl=en.

Michael Bravo

unread,
Sep 26, 2011, 4:14:15 AM9/26/11
to percona-d...@googlegroups.com
Well, as you probably know if you have streamed backups, this .tar.gz is not a "real" tar, and as far as I understand, there is no way to untar it to get a normal directory. It contains a small .cnf file and then a raw backup stream. 

The backup command I use is:

/usr/bin/innobackupex-1.5.1 --stream=tar ./ | gzip -c -9 > /mnt/backups/mysql/backup.`date +%d%m%Y%H%M%S`.tar.gz


Will Gunty

unread,
Sep 26, 2011, 4:24:12 AM9/26/11
to percona-d...@googlegroups.com
I've never had any problems treating it as a normal tar file.  Below is the normal command I use for server population:
                                                                                         
innobackupex --stream=tar ./ --slave-info --user=<USER> --password=<PASSWORD> | ssh <NEWHOST> "tar xfi - -C <DESTDIR>"

Seeing as this is using the stream as a tar and expanding on the other end, you should be able to just expand the file you have and get what you need.  

-- 
Will Gunty
Sent with Sparrow

--
You received this message because you are subscribed to the Google Groups "Percona Discussion" group.

Baron Schwartz

unread,
Sep 26, 2011, 8:38:40 AM9/26/11
to percona-d...@googlegroups.com
Michael,

Be sure you use the -i option to tar, as the documentation states.


--
Chief Performance Architect at Percona <http://www.percona.com/>
+1 (888) 401-3401 x507
Calendar: <http://bit.ly/baron-percona-cal> (Eastern Time)
Percona Live Conference comes to London! <http://www.percona.com/live>

Steven Ayre

unread,
Sep 26, 2011, 4:22:59 AM9/26/11
to percona-d...@googlegroups.com
1. Extract it using "tar -zxif".
You *must* use the -i flag, as otherwise certain files in the archive won't be extracted. Michael, is that what you mean by not a 'real' tar?

2. Run innobackupex to prepare the backup (this replays from the logs transactions that hadn't finished being committed which puts the ibdata into a good state)
http://www.percona.com/docs/wiki/percona-xtrabackup:innobackupex:how_to_recipes#apply_the_innodb_logs

3. Copy back into place. innobackupex gives a --copy-back option that'll do this for you, or you can do it manually.
http://www.percona.com/docs/wiki/percona-xtrabackup:innobackupex:how_to_recipes#restore_the_data

4. Start mysqld

-Steve




--
You received this message because you are subscribed to the Google Groups "Percona Discussion" group.

Michael Bravo

unread,
Sep 27, 2011, 6:36:23 AM9/27/11
to percona-d...@googlegroups.com
Thanks everyone, the procedure is clear now. Baron, I think none of the documentation I read has mentioned the -i switch for the tar, thus the confusion. It might help to expand the examples/howto section of the innobackupex documentation on your website to include a restore from streamed backup.

Baron Schwartz

unread,
Sep 27, 2011, 8:16:11 AM9/27/11
to percona-d...@googlegroups.com
Michael,

Can you point to a specific place where tar is mentioned without the -i
flag? We surely need to fix this and provide good examples. There is
another issue: the documentation is migrating from wiki to a
documentation tool called Sphinx, and we currently have one foot in
both worlds. The new docs are here:
http://www.percona.com/doc/percona-xtrabackup/ The release engineering
and docs team is working on finishing the migration.

Baron

Johann Vincent Paul Tagle

unread,
Sep 27, 2011, 8:13:13 PM9/27/11
to percona-d...@googlegroups.com
Hi Baron,

I remember making a mistake on this too.  I think it's because if you're like me who like to browse through pages, skipping lines and just look for commands, it is easy to miss the line that says "To extract the resulting tar file, you must use the -i option, such as tar -ixvf backup.tar" in http://www.percona.com/doc/percona-xtrabackup/howtos/recipes_ibkx_stream.html.  

Having used just "tar xvf" without the -i for years, I've come to think there's no other option  needed in any other case.  I guess it would help if on the same page there's an example to untar, or at least put an emphasis/highlight on the line that says you must use the -i option.

Johann

--
You received this message because you are subscribed to the Google Groups "Percona Discussion" group.

Michael Bravo

unread,
Sep 28, 2011, 3:45:35 AM9/28/11
to percona-d...@googlegroups.com
On Tuesday, September 27, 2011 4:16:11 PM UTC+4, Baron Schwartz wrote:
Michael,

Can you point to a specific place where tar is mentioned without the -i
flag?  We surely need to fix this and provide good examples.  There is
another issue: the documentation is migrating from wiki to a
documentation tool called Sphinx, and we currently have one foot in
both worlds.

Indeed, I was referring to the wiki version (e.g. http://www.percona.com/docs/wiki/percona-xtrabackup:innobackupex:how_to_recipes ) as opposed to the link to the new docs you and Johann provided. Anyway, there's now a "note" on the -i switch in the wiki, too, which I don't remember seeing there before - either it wasn't there and has been added, or I have missed it. In either case, all is good now, and thanks for the good works!

-- 
Michael Bravo

Steven Ayre

unread,
Sep 29, 2011, 1:20:58 PM9/29/11
to percona-d...@googlegroups.com
For your education (and my own)... the reason -i is required is it tells tar to ignore the end of an archive and keep extracting anything past that. That allows you to cat multiple tar files together to form a single tar file, and that's effectively what the innobackupex script is doing to put together different files taken from different sources (xtrabackup output plus files from the harddrive). Since most files contain only a single archive it's not normally needed which'll be why you'd never used it before.

-Steve


--
You received this message because you are subscribed to the Google Groups "Percona Discussion" group.
Reply all
Reply to author
Forward
0 new messages