![]() |
MySQL Logical Backup |
You can encrypt the output of `mysqldump` using various encryption methods such as OpenSSL, GPG, or native MySQL encryption.
Here's an example of how to encrypt the output of `mysqldump` using OpenSSL:
1. First, create a MySQL backup using `mysqldump` command:
mysqldump -u username -p database_name > backup.sql
2. Encrypt the backup file using OpenSSL command:
openssl aes-256-cbc -a -salt -in backup.sql -out backup.sql.enc
In this command, the `aes-256-cbc` is the encryption method, `-a` is to encode the output in base64, `-salt` adds a salt value to make the encryption more secure, `-in` specifies the input file (the backup file you created in step 1), and `-out` specifies the output file (the encrypted backup file).
3. Enter a password when prompted by OpenSSL to encrypt the backup file.
Note that anyone who has access to both the encrypted backup file and the encryption password will be able to decrypt the file. So, make sure to store the encrypted backup file and the encryption password securely.
e.g.:
MySQL file encryption & decryption command line:
encryption:
openssl enc -aes-256-cbc -in /path/example.sql -out /path/example.filedecryption:
openssl enc -aes-256-cbc -d -in /path/example.file > /path/example.sql
You can also automate this process using a script to encrypt your `mysqldump` backups on a regular basis.
No comments:
Post a Comment