-
#!/bin/bash
-
prefixe=backup
-
suffixe=$(date +%Y%m%d)
-
filename=$prefixe$suffixe.sql
-
host=host
-
database=database
-
user=user
-
characterSet=UTF8
-
mysqldump –skip-comments \
-
–complete-insert \
-
–default-character-set=$characterSet \
-
–no-create-info \
-
–skip-add-locks \
-
–skip-opt \
-
–host $host \
-
–user $user \
-
-p $database > $filename
-
sed -i “1iuse $database;\nSET CHARACTER SET ‘$characterSet’;” $filename
-
exit 0