Monday, July 25, 2011

MySQL "Push" backup strategy

A "pull" backup strategy can be achieved by a MySQL replication.

Alternatively, a "push" backup strategy can also be achieved through cron or task scheduler with the following 2-step strategy:

1. take a backup of the database

> mysqldump [options] database > backup.sql

2. send or dump the backup to the remote database

> mysql -u<user> -p<password> -h<remotehost> [options] < backup.sql

Note: the second step should have an explicit password, it should not be blank; to avoid prompt.

You can then add this to your cronjob or Task Scheduler (on Windows) to execute at a certain interval and frequency.

No comments:

Post a Comment