Wednesday, March 16, 2022

Backup Progress, How?

 I have been wondering how to do this as we need to allow users to perform backup and give them a good estimate on when said backup will be completed; as in my end where the database is external (MariaDB), then I need to run an external MySQLDump.exe.  The beauty of this is while backup is in progress running on a separate thread, they can continue working on their app without waiting for the backup completion.

Why is it important for me to show a progress bar as an indicator that the backup process has been completed?  Well it is because if they quit the app ahead of the backup completion, it will also quit the backup process and the backup will most probably be incomplete as harddisk writing is done gradually by the backup process.  So we need something like this that shows them when the backup process is still in progress:




But again how?  The backup completion is affected by file size and whether said database is local or on a remote location.  So originally, we perform guesstimates of how long it normally takes but that is not good enough.  And we definitely cannot use:

DO WHILE .T.
   IF FSIZE(m.lcBackup) > 0
      Exit
   ENDIF
ENDDO

As depending on your RAM and free memory, a diskwrite for the backup may happen several times gradually increasing its size; and when the first HDD write happens, your app with the approach above will deem it already complete.