0

I use basic_managed_mapped_file and I want to backup the file while the program is running.

How can I make sure the data is written to disk for the backup?

1 Answer 1

0

The answer is logically "yes".

The operating system will make sure that the data is written, I believe even if your process would crash next.

However, if you

  • must be sure that the data hit the disk before doing anything else
  • need to ensure that data hits the disk in any particular order (e.g. journaling/intent logging)
  • need to be sure that data is safely written in the face of e.g. power failure

then you will need to add a disk sync call on most OS-es. If you require this level of detail (and worse, in portable fashion), the topic quickly becomes hard, and I defer to

eat my data: how everybody gets file IO wrong from Stewart Smith

I've also mirrored the video/slides just in case (see here)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.