Topic: Backup

Hi All,
On 7/4/20 jean.brezhonek was kind enough to provide the following procedure to create a backup file of my database file.
-
procedure MenuClick1 (Sender: string);
begin
   CopyFile('sqlite.db', 'backup/backup '+ FormatDateTime('dd-mm-yyyy hh-nn-ss', now)+'.db');
end;

-
I created a Backup Folder in my project folder as he suggested. This routine works great.  It copies my data file along with the current date and time.
-
However, this is what I would like to do and here's why.  Each time the user signs out of my program it creates a new backup file.  I'm thinking that over time there will be lots of backup files in my folder.  Assume l'm using he program once every day, that's about 30 backups per month.  Because this procedure will be automatic, the user will not see these files unless they knew where to look.
-
What I did was to remove the date and time from the procedure.  This works fine. However it creates and overwrites the old file.  This is also OK by me since it will be the latest backup file.  However Date Modified always shows the same date and time. In my case
9/5/2020 1:39 pm.
-
I would like have it show the date and time that the file was actually backed up.  I noticed a PreserveTime: setting for the CopyFile command.  I don't really know, but I'm guessing this setting might use the actual date and time?  However I can't get it to work.  I'm a total novice using Pascal so I'm sure that's most of my problem.
-
Any thoughts will be appreciated.
Thanks, Frank

Re: Backup

Hi All,

I've been doing some experimenting on my Backup File date issue.
-
When I was testing my backup procedure I had not changed any data in my program.  So the file date and time was not changing in Explorer
-
However when I added some data to my program and then did a backup, the file date and time did change to the proper date and time.
-
So I'm assuming that data has to be changed in MVD in order for the Date Modified info to change when the CopyFile procedure is executed?  If this is true then it looks like I'm OK.  Because when a user opens up the program, they will most likely be adding information to the database.
-
Please let me know if I'm incorrect in my assumption.
-
Thanks, Frank

3 (edited by derek 2020-09-07 00:33:22)

Re: Backup

Hi Frank,
Yes, I think a change to the data is needed for the date modified to be updated.
However, you could simply add a table that holds a single row with a date/time stamp that gets automatically updated whenever your application is accessed and that will force a change to the date modified, even if the user doesn't manually change anything (please see attached).  It's something I use so I can see when someone was last logged on.
In the attachment, there is also an example of how, if you want to use the 'single click' option, you can delete a record (something you were asking about in another post).
Derek.

Post's attachments

Attachment icon frank single click2.zip 517.94 kb, 272 downloads since 2020-09-07