Last active
March 19, 2025 12:06
-
-
Save pugsley/2914b9c0d1e7b866eab2a4cc0ceb0ead to your computer and use it in GitHub Desktop.
Revisions
-
pugsley revised this gist
May 16, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -36,7 +36,7 @@ gzip -d [filename].sql.gz ## Clean up backups ``` cd [dir] && ls -tp | grep -v '/$' | tail -n +8 | xargs -I {} rm -- {} ``` Keep the latest 7 files in `[dir]`. -
pugsley revised this gist
May 9, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -44,6 +44,6 @@ Keep the latest 7 files in `[dir]`. References: https://www.everythingcli.org/secure-mysqldump-script-with-encryption-and-compression/ http://stackoverflow.com/questions/25785/delete-all-but-the-most-recent-x-files-in-bash -
pugsley revised this gist
May 9, 2016 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -46,4 +46,4 @@ Keep the latest 7 files in `[dir]`. References: https://www.everythingcli.org/secure-mysqldump-script-with-encryption-and-compression/ http://stackoverflow.com/questions/25785/delete-all-but-the-most-recent-x-files-in-bash -
pugsley revised this gist
May 9, 2016 . 1 changed file with 7 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,6 +34,13 @@ gzip -d [filename].sql.gz ``` ## Clean up backups ``` ls -tp [dir] | grep -v '/$' | tail -n +8 | xargs -I {} rm -- {} ``` Keep the latest 7 files in `[dir]`. -
pugsley revised this gist
Apr 29, 2016 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,6 @@ Generate openssl keys: ``` openssl req -x509 -nodes -newkey rsa:2048 -keyout mysqldump-key.priv.pem -out mysqldump-key.pub.pem ``` Create a mysql default file: ``` -
pugsley revised this gist
Apr 29, 2016 . 1 changed file with 10 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,7 @@ Bash script: #!/bin/bash DATE=`date +%Y-%m-%d-%H-%M-%S` ARCHIVE=${DATE}.sql.gz.enc MYSQLINFO=~/.mysqldump DATABASE=databasename PUBLIC_KEY=~/.mysqldump-key.pub.pem @@ -28,6 +28,15 @@ mysqldump --defaults-extra-file=${MYSQLINFO} ${DATABASE} --single-transaction -- | openssl smime -encrypt -binary -text -aes256 -out ${ARCHIVE} -outform DER ${PUBLIC_KEY} ``` Decrypt & decompress ``` openssl smime -decrypt -in [filename].sql.gz.enc -binary -inform DEM -inkey mysqldump-secure.priv.pem -out [filename].sql.gz gzip -d [filename].sql.gz ``` References: https://www.everythingcli.org/secure-mysqldump-script-with-encryption-and-compression/ -
pugsley revised this gist
Apr 29, 2016 . 1 changed file with 0 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,9 +23,6 @@ MYSQLINFO=~/.mysqldump DATABASE=databasename PUBLIC_KEY=~/.mysqldump-key.pub.pem mysqldump --defaults-extra-file=${MYSQLINFO} ${DATABASE} --single-transaction --routines --events --triggers \ | gzip -c \ | openssl smime -encrypt -binary -text -aes256 -out ${ARCHIVE} -outform DER ${PUBLIC_KEY} -
pugsley created this gist
Apr 29, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ Generate openssl keys: ``` openssl req -x509 -nodes -newkey rsa:2048 -keyout mysqldump-key.priv.pem -out mysqldump-key.pub.pem ``` Enter whatever at the prompts. Create a mysql default file: ``` # ~/.mysqldump [mysqldump] host = host.here.com user = user password = "password" ``` Bash script: ``` #!/bin/bash DATE=`date +%Y-%m-%d-%H-%M-%S` ARCHIVE=${DATE}.sql.enc.gz MYSQLINFO=~/.mysqldump DATABASE=databasename PUBLIC_KEY=~/.mysqldump-key.pub.pem echo ${DATE} echo ${ARCHIVE} mysqldump --defaults-extra-file=${MYSQLINFO} ${DATABASE} --single-transaction --routines --events --triggers \ | gzip -c \ | openssl smime -encrypt -binary -text -aes256 -out ${ARCHIVE} -outform DER ${PUBLIC_KEY} ``` References: https://www.everythingcli.org/secure-mysqldump-script-with-encryption-and-compression/