If using DBFs (SQL has rollback functionality).
A5 Incremental backup is for disaster recovery.
-- Maintain a fixed number of rollback points and include selected group/s of tables that manage themselves.
At the start of a routine where many tables will be updated, simply call backitup() and Set a flag to prevent user collision.
If the full update does not complete, the relevant data files prior to that are fully intact. Otherwise release the flag.
This is working code.
The files will be numbered from 1 to n with the oldest one always deleted. The next backup will use that number and delete the next and around to 1.
Any improvements welcome and maybe an Xdlg for recovery.
A5 Incremental backup is for disaster recovery.
-- Maintain a fixed number of rollback points and include selected group/s of tables that manage themselves.
At the start of a routine where many tables will be updated, simply call backitup() and Set a flag to prevent user collision.
If the full update does not complete, the relevant data files prior to that are fully intact. Otherwise release the flag.
Code:
FUNCTION Backitup AS C () 'Can use parameters for any of the specific settings highlighted Srvrdrv = left(:a5.get_path(),3) 'Will pick up the drive letter how_many=[COLOR="#0000FF"][B][I] 20 [/I][/B][/COLOR] 'Retain the last how_many-1 backups zip_filename = Srvrdrv +[COLOR="#0000FF"][B][I]Foldername[/I][/B][/COLOR]+ chr(92) + [COLOR="#0000FF"][B][I]Zipname[/I][/B][/COLOR] for i=1 to how_many If .not. file.exists(full_zip_filename+str(i,2,0)+".zip") then thiszip=full_zip_filename+str(i,2,0) exit for End if next if i=how_many ' Has reached the limit prepare next backup to begin at 1 i=0 end if If file.exists(full_zip_filename+str(i+1,2,0)+".zip") then file.remove(full_zip_filename+str(i+1,2,0)+".zip") end if FILE.ZIP(thiszip,:a5.get_path()+ chr(92) +"[COLOR="#0000FF"][B][I]invL*.*[/I][/B][/COLOR]") ..... FILE.ZIP(thiszip,:a5.get_path()+ chr(92) +"[COLOR="#0000FF"][B][I]gltran.d??[/I][/B][/COLOR]") ui_msg_box("Zipped Database","Database saved as"+crlf()+thiszip) END FUNCTION
The files will be numbered from 1 to n with the oldest one always deleted. The next backup will use that number and delete the next and around to 1.
Any improvements welcome and maybe an Xdlg for recovery.