-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdump.sh
More file actions
executable file
·30 lines (29 loc) · 775 Bytes
/
dump.sh
File metadata and controls
executable file
·30 lines (29 loc) · 775 Bytes
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
#!/bin/sh
source /root/.mysqluser
# a file containing
# USER
# PASS
# BACKUPPATH
# ZIP (y/n) # whether to bzip the databases or not
# DATE (y/n) # whether to append the date at the end or not
DATABASES="$(mysql --user=$USER --password=$PASS -Bse 'show databases')"
#echo $DATABASES
cd $BACKUPPATH
if [ "$DATE" == "y" ]; then
APPENDDATE="-"$(date +%m-%d-%y)
else
APPENDDATE=""
fi
for db in ${DATABASES[@]}
do
if [ $db == "information_schema" ]
then
continue
fi
# echo ${db}-$(date +%m-%d-%y).sql.bz2 is being saved in $BACKUPPATH
if [ "$ZIP" == "y" ];then
mysqldump --user=$USER --password=$PASS $db --single-transaction -R | bzip2 -c > ${db}.sql.bz2
else
mysqldump --user=$USER --password=$PASS $db --single-transaction -R > ${db}.sql
fi
done