-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Muhammed Hussein Karimi <info@karimi.dev>
- Loading branch information
1 parent
4a8ed0c
commit 2668b5c
Showing
2 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 characters
This file contains 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 characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -o pipefail -ue | ||
|
||
. /opt/parmincloud/backups/utils | ||
|
||
if [ -z "$MYSQL_HOST" ]; then | ||
log "You need to set the MYSQL_HOST environment variable." | ||
exit 1 | ||
fi | ||
if [ -z "$MYSQL_USER" ]; then | ||
log "You need to set the MYSQL_USER environment variable." | ||
exit 1 | ||
fi | ||
if [ -z "$MYSQL_PORT" ]; then | ||
log "You need to set the MYSQL_PORT environment variable." | ||
exit 1 | ||
fi | ||
if [ -z "$MYSQL_PASSWORD" ]; then | ||
log "You need to set the MYSQL_PASSWORD environment variable." | ||
exit 1 | ||
fi | ||
|
||
BACKUP_OUT=/tmp/dump.sql.gz | ||
|
||
log "Creating dump of database" | ||
mysqldump \ | ||
--host="${MYSQL_HOST}" \ | ||
--port="${MYSQL_PORT}" \ | ||
--password="${MYSQL_PASSWORD}" \ | ||
--user="${MYSQL_USER}" \ | ||
--single-transaction \ | ||
--get-server-public-key \ | ||
--all-databases | gzip -9 > "${BACKUP_OUT}" | ||
|
||
echo "${BACKUP_OUT}" |