mysqldump DB backups

To do a manual backup a mysql database, use mysqldump with the following syntax:

mysqldump -h hostname -u user -pPassword dbname >/path/to/file

Note that hostname is optional and will default to localhost. Depending on some settings user and password may be optional as well.

Now, asssuming you are using a linux shell, if we want to have rotating logs,  add the date name and stick the whole line in a script running in cron:

mysqldump -h hostname -u root mydb > /path/to/backup/$(date +%a)

Leave a Reply

Your email address will not be published. Required fields are marked *