-
Notifications
You must be signed in to change notification settings - Fork 3
/
mysql_backup_dump.sh
38 lines (28 loc) · 1.19 KB
/
mysql_backup_dump.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
DBNAME=unipal_db
TESTDBNAME=unipal_test_db
DBUSER=root
read -sp "Enter password for ${DBUSER} user: " DBPASS
echo
echo "======= STARTING MAIN DB EXPORT ======="
echo
echo "Dumping (FULL SQL) for MAIN database"
mysqldump --user=$DBUSER --password=$DBPASS --single-transaction $DBNAME > "backups/${DBNAME}.sql"
echo
echo "Dumping (SCHEMA ONLY) for MAIN database"
mysqldump --user=$DBUSER --password=$DBPASS --single-transaction --no-data $DBNAME > "backups/${DBNAME}_schema.sql" # -d also works the same
echo
echo "Dumping (DATA ONLY) for MAIN database"
mysqldump --user=$DBUSER --password=$DBPASS --single-transaction --no-create-info $DBNAME > "backups/${DBNAME}_data.sql" # -t also works the same
echo
echo "========== EXPORT COMPLETE =========="
echo
echo "======= STARTING TEST DB EXPORT ======="
echo
echo "Dumping (FULL SQL) for TEST database"
mysqldump --user=$DBUSER --password=$DBPASS --single-transaction $DBNAME > "backups/${TESTDBNAME}.sql"
echo
echo "Dumping (DATA ONLY) for TEST database"
mysqldump --user=$DBUSER --password=$DBPASS --single-transaction --no-create-info $DBNAME > "backups/${TESTDBNAME}_data.sql" # -t also works the same
echo
echo "========== EXPORT COMPLETE =========="
read