Skip to content

Commit

Permalink
adds timestamp to filename / adds --no-tablespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
joanfabregat committed Jul 17, 2024
1 parent 781f3d4 commit e68a7d7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions run.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#!/bin/bash

timestamp=$(date -u +"%Y-%m-%dT%H%M%SZ")

# Dump MySQL database
mysqldump -h $MYSQL_HOST -P $MYSQL_PORT -u $MYSQL_USER -p$MYSQL_PASSWORD $MYSQL_DATABASE > /tmp/$MYSQL_DATABASE.sql | gzip -c > /tmp/$MYSQL_DATABASE.sql.gz
mysqldump -h $MYSQL_HOST -P $MYSQL_PORT -u $MYSQL_USER -p$MYSQL_PASSWORD --no-tablespaces $MYSQL_DATABASE > /tmp/$MYSQL_DATABASE.sql | gzip -c > /tmp/$MYSQL_DATABASE.sql.gz

# Upload to S3
aws s3 cp /tmp/$MYSQL_DATABASE.sql.gz s3://$S3_BUCKET$S3_PREFIX$MYSQL_DATABASE.sql.gz
aws s3 cp /tmp/$MYSQL_DATABASE.sql.gz s3://$S3_BUCKET$S3_PREFIX${timestamp}.sql.gz

# Remove dump
rm /tmp/$MYSQL_DATABASE.sql.gz

0 comments on commit e68a7d7

Please sign in to comment.