I am in the problem that I need to export a DB but I would like to learn how to export it and encrypt it with GPG (using symmetric encryption). My command looks something like the following:
$ mysqldump -u user_db -p name_db | gpg -a --cipher-algo AES -o name_db.sql.gpg
But when I run it, my terminal goes into standby mode and I can't even Ctrl + Cfinish the process. I closed terminal and when I tried again, just after putting the MySQL password, I got:
gpg: no valid OpenPGP data found.
gpg: processing message failed: Unknown system error
I understand that the pipe symbol "|" it grabs the printed content of command1 so that command2 can grab it, but I can't get it to work.
$ comando1 | comando2
Note: I don't want to save the file .sql
and then encrypt it, rather I want to do it on top of the same command.
The problem was that you were missing the encrypt(
--encrypt
) flag:At that point you will have two entries to add, the database password and the user ID of your gpg, in my case my user is
"Cesar Bustios"
. In one line:The only problem is that the MySQL warning will jump to you since it is insecure to put the password in the same terminal.
If the file exists it will ask you for confirmation, you can pass the flag
--yes
at the end to force the file to be overwritten: