How do you set up a back up file?

How do you set up an automatic back up file for each data base?

I put this code snippet into the .Initialize procedure of most of my databases:

makefolder "Backup files"
saveacopyas "Backup files/" + info("databasename") + " backup"

Then, if the active database goes really bad I’ve only lost whatever I’ve done since opening it. If you want your backup folder to be somewhere other than in your current folder, use the dbfolder( function to place it.

The makefolder statement ensures that there is always a backup folder to take the backups - if it is already there, nothing changes.

An alternative approach is to always use a .closefile procedure to close your database and put the backup code in there - this tends to be less reliable because it’s possible to close the file without triggering the procedure.

Automatic backups can give a false sense of security - it’s very easy to over-write a good file with a corrupted one. A belt-and-braces solution is to also run a copyfolder procedure independently of the automatic backup, perhaps manually. This one could copy your backup folder, your active folder or even both. It all depends how important your data is.

I would recommend enabling Time Machine.

Also, Panorama automatically keeps previous versions of each database using the standard “Versions” feature of macOS. You can go back to a previous version using the Revert To command. There is also a free program called “Revisionist” that can allow you to access previous revisions of a file (this works with many apps, not just Panorama).