Topic: Replace the backup file

Welcome

I used this code to make a backup copy, and I used the time and date to create a new file every time

Now I want to make the file with one name, and when I make a backup copy, it will replace the old file with the new file




procedure form2_Button8_OnClick (Sender: TObject; var Cancel: boolean);
begin
  if CopyFile('sqlite.db', 'Backup\backup.db') then showmessage('backup ok');
end;

Re: Replace the backup file

Try replacing the backup.db with the date and time format

procedure form2_Button8_OnClick (Sender: TObject; var Cancel: boolean);
begin
  if CopyFile('sqlite.db', 'Backup\'+FormatDateTime('mm_dd_yyyy_hh_nn_ss', now)+'.db') then showmessage('backup ok');
end;
brian

Re: Replace the backup file

brian.zaballa wrote:

Try replacing the backup.db with the date and time format

procedure form2_Button8_OnClick (Sender: TObject; var Cancel: boolean);
begin
  if CopyFile('sqlite.db', 'Backup\'+FormatDateTime('mm_dd_yyyy_hh_nn_ss', now)+'.db') then showmessage('backup ok');
end;


Thank you
I used this in the past, but it created a lot of files and took up space on the hard drive
I want the name to be fixed, and when the button is pressed, it will replace the old file with the new file

Re: Replace the backup file

Oh, is there any problem with what you are doing? Copying sqlite.db to backup.db? It will always replace backup.db I think. Can you cite some example of what you really want to do so that it is easier to understand like citing filenames, what "one name" are you referring to, etc.

brian