Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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
add comment

1 Answer 1

up vote 1 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
add comment

Your Answer

 
discard

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.