Topic: Restore
Hi, I have create a backup procedure by script for the database sqlite.db. But how can I make a restore procedure? As I know I can not restore the file when the database is active . Any idea???
My Visual Database → General → Restore
Hi, I have create a backup procedure by script for the database sqlite.db. But how can I make a restore procedure? As I know I can not restore the file when the database is active . Any idea???
Hello v_pozidis, we cannot restore a database that is in use. You need to close the application and copy "sqlite.db" from the backup and paste it in your program folder in order to replace the existing one.
Destiny
Hi, I have create a backup procedure by script for the database sqlite.db. But how can I make a restore procedure? As I know I can not restore the file when the database is active . Any idea???
Actions to restore the database (copying files) can be performed from a batch file. So the scenario is:
1. The program creates a batch file, runs it and exits
2. A small delay (1-2 seconds) is made in the batch file so that the program is guaranteed to close and release access to the database file.
3. In the batch file, the database file is copied.
4. The main program is launched in the batch file.
Done: The database has been restored from a backup.
I had already used a Batch file some time ago but I abandoned the idea because the database file is not replaceable in use of this one.
Thank you...I will try to create a script using Lazarus pascal to rename and copy the file from the backup folder to the application folder or does any one has already the script???
Try this one.
Your solution works, how does it manage to replace the sqlite in use.
Form1.close; // will also close the database
// replace database with the selected backup
CopyFile(OpenDialog.FileName, ExtractFilePath(Application.ExeName)+'\sqlite.db');
// re open the application
OpenFile('samplebackup.exe');
Just a hunch that closing the main(Form1 in the sample) form will also close the database connection, then after that, you can replace the sqlite.db by the backup. Then running the executable afterwards.
Thanks, the code is indeed working.
What I can not understand is that if the program runs the database is active. So with your example when you close the program Form1.close how does the function replace works???
In the code there is a part that saves the database and another part that closes the program, restores the database and re-opens the program, all of this is almost invisible.
What I can not understand is that if the program runs the database is active. So with your example when you close the program Form1.close how does the function replace works???
You must first backup the database using the backup button. The button will backup your current sqlite.db to [filename].dbbak using SaveDialog
Then the Add record button is just to populate the table to see if populated table will be replaced by the backup.
To backup, you then click Backup button in which the program will ask the user for a file(backup, the one you save with Backup button) using the OpenDialog, then when the user select [filename].dbbak, it will close Form1, then replace sqlite.db with the user's selected [filename].dbbak, then reopen the program
I have understood your software script. The program works correct. My question is how is it possible when you close the program to change the database ...,'' it will close Form1, then replace sqlite.db with the user's selected [filename].dbbak, then reopen the program''
.... i will use your script. .. thanks
I have understood your software script. The program works correct. My question is how is it possible when you close the program to change the database ...,'' it will close Form1, then replace sqlite.db with the user's selected [filename].dbbak, then reopen the program''
.... i will use your script. .. thanks
There is an assumption that when the main form close event occurs, the connection to the database file is closed, and this happens before the application terminates. And judging by the above code, this assumption is correct.
My Visual Database → General → Restore
Powered by PunBB, supported by Informer Technologies, Inc.
Theme Hydrogen by Kushi