-
-
Save reina3596/f151a8fc9862d3e949d60aff66869a96 to your computer and use it in GitHub Desktop.
Send MySQL Backup to Google Cloud Storage(GCS)
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
#!/bin/bash | |
TIMESTAMP=$(date +"%Y-%m-%d_%H-%M-%S") | |
BACKUP_DIR="/home/ubuntu/backup/$TIMESTAMP" | |
MYSQL_USER="****" | |
MYSQL=/usr/bin/mysql | |
MYSQL_PASSWORD="****" | |
MYSQLDUMP=/usr/bin/mysqldump | |
mkdir -p "$BACKUP_DIR/" | |
databases="db1 db2 db3 db4" | |
for db in $databases; do | |
$MYSQLDUMP --force --opt --user=$MYSQL_USER -p$MYSQL_PASSWORD --databases $db --routines | gzip > "$BACKUP_DIR/$db-$TIMESTAMP.gz" | |
gsutil cp $BACKUP_DIR/$db-$TIMESTAMP.gz gs://mydb-$db-backup/ | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment