最佳答案
I have a Bash script that creates a .tar.gz file, encrypts, and then sends it to a drive. However, I cannot open the .tar.gz file afterwards. Here is my process...
Bash script that encrypts.
#!/bin/sh
# Tar the automysqlbackup directory
tar -zcf "red-backup-$(date '+%Y-%m-%d').tar.gz" /var/lib/automysqlbackup/
# Encrypt the tar file
openssl aes-256-cbc -a -salt -in "red-backup-$(date '+%Y-%m-%d').tar.gz" -out "red-backup-$(date '+%Y-%m-%d').tar.gz.enc" -pass 'pass:MySecretPWD'
# Remove the original tar file
rm -rf "red-backup-$(date '+%Y-%m-%d').tar.gz"
# Upload to Google Drive
gdrive upload --file "red-backup-$(date '+%Y-%m-%d').tar.gz.enc" -p "jofhriout849uioejfoiu09"
Then I download the file and use
sudo openssl aes-256-cbc -e -in red-backup-2016-09-22.tar.gz.enc -out red-backup-2016-09-22.tar.gz
I then enter the passphrase for my file twice and I now get a file called
red-backup-2016-09-22.tar.gz
When I then try
sudo tar -zxvf red-backup-2016-09-22.tar.gz
I get
gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
I have also tried renaming the file .tar and also tried
sudo tar xvf red-backup-2016-09-22.tar.gz
and
sudo tar xvf red-backup-2016-09-22.tar
tar: This does not look like a tar archive
tar: Skipping to next header
tar: Exiting with failure status due to previous errors
Where am I going wrong?