Problem
Compress large data sets into multiple volume files and crypt the archive with a symmetric key encryption.
Analysis
Use tar to create multi-volume archives.
Use gpg to crypt the archive. Note that gpg uses compression algorithm to compress the data before the data is encrypted.
Solution
Compressing
Create multiple volumes with tar with the following command:
$ tar -c --preserve --numeric-owner -L2048 \ -f ns2-backup.1.tar -f ns2-backup.2.tar -f ns2-backup.3.tar ./ns2
This command takes all data from local subdirectory ns2 and creates 4GB archive volumes. As a result you will get three 4GB file ns2-backup.1.tar, ns2-backup.2.tar and ns2-backup.3.tar. Tar does not prompt you for any output. The –preserve switch preserves the permissions.
The –numeric-owner sets numeric IDs instead of user names.
-L sets the number of bytes of a single archive.
Crypting
Now you can crypt the archives with the following command:
$ gpg -c ns2-backup.1.tar
The command will ask you twice for your pass phrase. Then it starts the encryption.
Caution: Before you delete your archived data, make sure you can recover your data from created archives (first from gpg and then from tar).
Resources
- tar – Using Multiple Tapes. http://www.gnu.org/software/tar/manual/html_section/Using-Multiple-Tapes.html
- GnuPG Homepage. http://www.gnupg.org/