Skip to content

Instantly share code, notes, and snippets.

@mattbloomfield
Created April 2, 2021 14:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattbloomfield/cf80a3e3487651e04dd7305ca8e8562d to your computer and use it in GitHub Desktop.
Save mattbloomfield/cf80a3e3487651e04dd7305ca8e8562d to your computer and use it in GitHub Desktop.
Saves the local DB to a file. If not supplied with a path, stored in /tmp/ with current timestamp
#!/bin/bash
## Saves the local DB to a file. If not supplied with a path, stored in /tmp/ with current timestamp
## Usage: fin db_dump [path]
# Forces whole job to error on failure
set -e
TRANSACTION_ID=$(date +"%Y-%m-%d_%H-%M-%S")
SAVE_PATH=$1
if [ $# -eq 0 ]
then
SAVE_PATH=/tmp/${MYSQL_DATABASE}_local_${TRANSACTION_ID}.sql
fi
fin db dump $SAVE_PATH
echo "Saved as ${SAVE_PATH}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment