سؤال

I have a Windows Task Job Running every night at 3 am that is backing up all the databases via a batch file, it backs up everything just fine.

However if someone is inserting a record into the database while the back up is running, it runs into an issue where it duplicates the insert query about 10-30 times.

User Inserts data into the MySQL database by a PHP webpage, once the insert is done PHP redirects the page to a fresh version of the current page so refreshing or hitting back the page will not do anything.

The duplicate entries happen only while the backup is running.

هل كانت مفيدة؟

المحلول

If you're using mysqldump be sure that you're using the transaction snapshot feature by enabling --single-transaction.

There's a lot of options that control how the dump is captured and what options to include.

My defaults:

mysqldump --create-options --extended-insert --add-drop-table --single-transaction --hex-blob
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top