MySQL Forums
Forum List  »  Newbie

Re: Migrating MySql from Debian to Windows
Posted by: Peter Brawley
Date: June 09, 2014 10:31PM

A mysqldump script, made eg with ...

mysqldump –uUSR –pPWD –K –E –A –R –f >some_backup_dir/mybackup.sql

... is a complete database description in SQL, so it's mostly independent of the underlying OS (if you handle case sensitivity correctly).

A reasonably safe approach is to save such a backup once per working day to another network computer, and to save those backup files offsite once a week or so. The more important the data, the shorter those intervals need to be. The question that needs an answer is, how much data can we afford to lose? When the answer is zero, you need offsite replication; otherwise run backups and save them offsite. An approach to *Nix backups is described at http://stackoverflow.com/questions/19664893/linux-shell-script-for-database-backup. When that approach is applied under Windows, you get a batch file like this ...

for /f "tokens=1-3 delims=/- " %%a in ('date /t') do set XDate=%%a%%b%%c
echo MySQL backup for %XDate%:
if exist %1\mysqlbak%XDate%.sql del %1\mysqlbak%XDate%.sql
"PATH_TO_MYSQL\bin\mysqldump" -uUSR -pPWD -A --add-drop-database -K -E -R >%1\mysqlbak%XDate%.sql

... where PATH_TO_MYSQL is the path to the mysql installation, and %1 is where the backup is to be written, passed to the batch file as a param.



Edited 3 time(s). Last edit at 06/09/2014 10:52PM by Peter Brawley.

Options: ReplyQuote


Subject
Written By
Posted
Re: Migrating MySql from Debian to Windows
June 09, 2014 10:31PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.