# stream + compress + crypt a backup

**URL:** <https://forums.percona.com/t/stream-compress-crypt-a-backup/3761>\
**Category:** Percona XtraBackup\
**Created:** [September 22, 2014, 2:28pm UTC](https://forums.percona.com/t/stream-compress-crypt-a-backup/3761 "2014-09-22T14:28:04Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![cristiano.politowski](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@cristiano.politowski](https://forums.percona.com/u/cristiano.politowski)\
**Post date:** [September 22, 2014, 2:28pm UTC](https://forums.percona.com/t/stream-compress-crypt-a-backup/3761/1 "2014-09-22T14:28:04Z")

</div>

Hi folks.

I’m making a incremental backup per month, and in the end of the month I want to stream, compress and crypt this folder. I was doing this way:

```auto

innobackupex --user="${USER}" --password="${PASS}" --stream=xbstream --compress "${BASE_DIR}" -encrypt="${CRYPT_ALG}" --encrypt-key-file="${BASE_DIR}"/key > /vagrant/backup.xbstream

```

Everything seems to work, but when I want prepare it:

```auto

xbstream -x -C /dir/backup < backup.xbstream
innobackupex --user="${USER}" --password="${PASS}" --decompress --decrypt="${CRYPT_ALG}" --encrypt-key-file="${BASE_DIR}"/key /dir/backup

```

a error occurred:

```auto

xb_stream_read_chunk(): wrong chunk magic at offset...

```

Searching I found this: [URL=“[Bug #1184830 “Xtrabackup fails with “xtrabackup\_55: Error writin...” : Bugs : Percona XtraBackup moved to https://jira.percona.com/projects/PXB](https://bugs.launchpad.net/percona-xtrabackup/+bug/1184830)”][https://bugs.launchpad.net/percona-x...p/+bug/1184830[/URL]](https://bugs.launchpad.net/percona-x...p/+bug/1184830%5B/URL%5D), that said to decrypt first. But how? If I run the second command first, It ask for a directory, not a file (backup.xbstream).

Someone can help me?  
Thanks and sorry by the poor English
