3

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.

1 Answer 1

2

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.

1
  • Thanks for posting your answer. I adapted it to use gpg. To tar/gpg/split: tar -cJvpf - inputdirectory/ | gpg --symmetric --cipher-algo aes256 | split -d -b 100m - outputfile.tar.xz.gpg. and to decrypt: cat outputfile.tar.xz.gpg.* | gpg -d | tar -xJvpf -
    – oksage
    Aug 21, 2022 at 23:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .