Aug
4

Simple MySQL Backup Bash Script

By bradj  //  Bash, Linux  //  No Comments

Wrote this script to backup a MySQL database of mine. Let me know if you have trouble using it :)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#!/bin/bash
# This script was created by Brad Janke
# www.bradjanke.com
# Please use with caution =D
# <3 Penguins....
DATE="$(date '+%Y_%m_%d_%H%M')"
# password associated with the user
PW=""
# the name of the user you will connect to the MySQL server with.  This user must have read access to the database you are attempting to backup
USER=""
# the name of the database you want to backup
DB=""
# Where the backup will be written to
FILE="$DB.$DATE.sql"
mysqldump -u $USER -p$PW $DB > $FILE && echo "$FILE written successfully...."
echo "FIN!"

Leave a comment

You must be logged in to post a comment.