Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I often use tar to backup my stuff in 4 gigabyte chunks to a directory on a FAT32-formatted disk, as documented here.

To get that done, I use the following command: tar -cvpj /path/to/directory/ | split -d -b 4000m - "backup.tar.bz2.".

I want to encrypt these tar.bz2.* files with openssl aes-256-cbc, if possible right after making a 4 GB chunk instead of after the whole backup job. I'd like to know the proper command to do that, and how to reconstitute the archive after creation.

share|improve this question
up vote 2 down vote accepted

How about this?

tar -cvpj /path/to/directory | openssl aes-256-cbc -kfile /path/to/enc.key | split -d -b 4000m - backup.tar.bz2.enc.

To extract:

cat backup.tar.bz2.enc.* | openssl aes-256-cbc -d -kfile /path/to/enc.key | tar xvjf -

EDIT: I noticed that split has --filter.

EDIT: Since cbc chains blocks, it makes it difficult to join. I put the split after the encryption to make this easier.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.