Skip to content

Instantly share code, notes, and snippets.

@refo
Created February 2, 2021 12:55
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 refo/3b9ee6aa8c9792528187eb6d97ff371c to your computer and use it in GitHub Desktop.
Save refo/3b9ee6aa8c9792528187eb6d97ff371c to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
DBNAME=$1
DIR=$2
DUMP=/usr/bin/mysqldump
PREFIX="${DBNAME}";
SUFFIX=$(date +"%F-%H%M%S");
FILENAME="${PREFIX}-${SUFFIX}.sql";
FILEPATH="${DIR}/${FILENAME}"
echo "Backing up ${FILEPATH}"
$DUMP "${DBNAME}" --result-file="${FILEPATH}"
# crontab -e
# /root/scripts/db-backup "db_name" /root/backup 2>&1 >> /root/backup/backup.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment