Ensuring data integrity mysqldump & # 8596; rsync

I use rsync to backup files on my server, and mysqldump to backup my database. Here is my concern:

mysqldump in my database takes about 30 seconds. I have a table with photos that stores information about the images that the user has uploaded, including the path to the file. I am worried about what happens when photos are uploaded or deleted within the 30 seconds required to complete mysqldump. If this happened, and I had to recover the rsync'd files and mysqldump data, I could then look at the database containing lines indicating deleted photos or missing lines for successful photo uploads.

How can I make sure mysqldump exactly matches rsync?

Thanks in advance, Brian

+3
source share
3 answers

Use LOCK TABLESto block any record activity from table backups. Then open them as soon as yours mysqldumpis complete.

+1
source

I think the answer is simple, just run rsync AFTER you finish mysqldump :) Thus, in the worst case, you will have several new files that are not in the db dump, but you will not have inconsistent db entries.

+1
source

MD5 mysqldump ( ) () rsync, , . mysqldump ( git svn vcs). git, , , , , , . , .

0

Source: https://habr.com/ru/post/1715393/


All Articles