I'v written a Python script in order to pack, encrypt and backup directories. Though, the heavy lifting is done by assembled commands passed to the shell using os.system(). The assembled commands look like this:
Packing:
cd /vault/backup/pictures; tar cf - vacation-201309 | xz -9 | gpg --symmetric --cipher-algo TWOFISH --digest-algo SHA512 --no-secmem-warning --yes --batch --passphrase-file /vault/keys/back_keyfile -o /vault/backup/upload/vacation-201309.tar.xz.gpg
Unpacking:
gpg --no-secmem-warning --yes --batch --passphrase-file /vault/keys/back_keyfile --decrypt /vault/backup/upload/vacation-201309.tar.xz.gpg | xzcat | tar xfv - -C /vault/backup/restore
It works actually quite good and robust, this is what the shell is really good in. Anyway, I want to make it more universal and convert it to pure Python. Is there a possibility to pipe data stream shell-like or do if have to iteratively
- Tar
- Compress
- Encrypt
respectively the other way around?
Any suggestions? Thank you very much.