# Error Using xbstream, compression, and encryption together

**URL:** https://forums.percona.com/t/error-using-xbstream-compression-and-encryption-together/2957
**Category:** Percona XtraBackup
**Created:** [September 22, 2013, 2:22am UTC](https://forums.percona.com/t/error-using-xbstream-compression-and-encryption-together/2957 "2013-09-22T02:22:39Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![trendier](https://avatars.discourse-cdn.com/v4/letter/t/85e7bf/32.png) [@trendier](https://forums.percona.com/u/trendier)
#### Post date: [September 22, 2013, 2:22am UTC](https://forums.percona.com/t/error-using-xbstream-compression-and-encryption-together/2957/1 "2013-09-22T02:22:39Z")

</div>

I am using this command:

innobackupex --encrypt=AES256 --encrypt-key-file=/usr/lib/backup/BACKUP.key --user=x --password=‘x’ --stream=xbstream /usr/lib/backup/ \> /usr/lib/backup/g.“$TIMESTAMP”.xbstream

Then I wanted to check if I can restore my file using:

xbstream -x \< /usr/lib/backup/g.2013-09-22\_07-30-35.xbstream -C /usr/lib/backup/res

but gives me the error:

xb\_stream\_read\_chunk(): wrong chunk magic at offset 0x0.

I tried decrypting the file first as well, which gives me an OK message for the decryption, but I get the same error when I run the xbstream command again.

How can I fix this?

---

<div class="post-metadata">

### Author: ![niljoshi](https://sea1.discourse-cdn.com/flex019/user_avatar/forums.percona.com/niljoshi/32/16889_2.png) [@niljoshi](https://forums.percona.com/u/niljoshi)
#### Post date: [September 24, 2013, 12:03am UTC](https://forums.percona.com/t/error-using-xbstream-compression-and-encryption-together/2957/2 "2013-09-24T00:03:36Z")

</div>

Hi,

Can you tell me which xtrabackup version you are using? Because looks like there are some bugs related to this.  
[URL][https://bugs.launchpad.net/percona-xtrabackup/+bug/1076063[/URL]](https://bugs.launchpad.net/percona-xtrabackup/+bug/1076063%5B/URL%5D)  
[URL][https://bugs.launchpad.net/percona-xtrabackup/+bug/1184830[/URL]](https://bugs.launchpad.net/percona-xtrabackup/+bug/1184830%5B/URL%5D)

One more thing that the stream must be decrypted first before read by xbstream so I would suggest to use both at the same time. something like

xbcrypt -d --a AES256 -f [COLOR=#252C2F]/usr/lib/backup/BACKUP.key | xbstream -x -C [COLOR=#252C2F]/usr/lib/backup/res

---

<div class="post-metadata">

### Author: ![trendier](https://avatars.discourse-cdn.com/v4/letter/t/85e7bf/32.png) [@trendier](https://forums.percona.com/u/trendier)
#### Post date: [September 24, 2013, 1:11am UTC](https://forums.percona.com/t/error-using-xbstream-compression-and-encryption-together/2957/3 "2013-09-24T01:11:00Z")

</div>

xtrabackup version 2.1.5 for Percona Server 5.1.70 unknown-linux-gnu (x86\_64) (revision id: 680)

I tried the command you gave me with a couple changes like adding -i for the input file, and it seems to have worked. I still have to try restoring the file to a new database to confirm if it is correct, but it looks good, and no error messages.

Here was the command that worked for me, for anyone looking for this answer:  
xbcrypt -d -a AES256 -f /usr/lib/backup/BACKUP.key -i myfile.xbstream | xbstream -x -C /usr/lib/backup/res

niljoshi, thanks so much! I will be testing these files tomorrow, if I don’t report back, you can assume it worked successfully.
