5.0 out of 5 based on 202 votes

Bewertung: 5 / 5

Stern aktivStern aktivStern aktivStern aktivStern aktiv


there are 2 tool for dump and import on Linux Shell.


For export you can use:


mysqldump -u <USER> -p <Database> > <SafeFile>.dmp


This create a file whith the database structure.


For import you can use:


mysql -u <USER> -p <Database> < <SafeFile>.dmp


This create a Database whith the structure from the backup File.


If you want zip your export use:


mysqldump -u <USER> -p <Database> | gzip > <SafeFile>.dmp


If you want create daily a dump and remove old dumps after 14 days this script for bash can help:


DATE=`date +%Y-%m-%d`

mysqldump -u $USER -p$PASS $DATABASE | gzip > /var/opt/mysqldump/daily-backup-$DATE.gz

find /var/opt/mysqldump -name "daily-backup-*" -atime +14 -exec rm {} \;