forked from databacker/mysql-backup
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathencrypt.sh
More file actions
25 lines (21 loc) · 707 Bytes
/
encrypt.sh
File metadata and controls
25 lines (21 loc) · 707 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
#
# post-processing backup script used to encrypt the backup file.
# Many thanks to Sascha Schieferdecker https://github.com/sascha-schieferdecker
# for providing it.
#
# to use, mount in /scripts.d/post-backup/secure.sh
#
# the symmetric encryption key should be mounted in /scripts.d/post-backup/mysqldump-key.pub.pem
# Encrypt and chmod backup file.
if [[ -n "$DB_DUMP_DEBUG" ]]; then
set -x
fi
if [ -e ${DUMPFILE} ];
then
openssl smime -encrypt -binary -text -aes256 -in ${DUMPFILE} -out ${DUMPFILE}.enc -outform DER /scripts.d/post-backup/mysqldump-key.pub.pem
mv ${DUMPFILE}.enc ${DUMPFILE}
chmod 600 ${DUMPFILE}
else
echo "ERROR: Backup file ${DUMPFILE} does not exist!"
fi