Saturday, April 03, 2021

Backing up your Clarion projects

SoftVelocity Clarion

Whenever you start work on a new project, it's too easy to forget to make backups. Even if you save your work often, what do you do if Clarion crashes, or you break something and need to go back to the previous version of the project? For US$99 DeveloperTeam has a nifty template you can use for automatic backups every time you do a compile. It's pretty automatic once you set it up, but it doesn't back up everything, just the really important bits (app file as txa, dictionary file as dctx) so it is very fast.
Another option is to use Zippy Backup Assist, a free utility I wrote for my Access97 development work after I threw away a whole day's work by mistake. You copy the Zippy.exe program into your project folder, as well as zip.bat, which does most of the work. Then you edit the zip.bat file and assign a name for the project. In this case, the name is "learn" and the project is called "Learning Clarion".
Zippy.exe calls the zip.bat file in the same folder as it is running from, and passes it a parameter, comprising the project name (set this using the ZIPPY= command in zip.bat) plus today's date (and time). It's written in Visual Basic 6, and runs fine in Windows 10 and 11.

Installation

Please download ZippySetup.exe which will also install the command line version of PKZIP called PKZIPC. (My installer and Zippy.exe is not signed. Sorry! But you can upload it to VirusTotal to check for malicious code.) There are two versions of the zip.bat file available:
  • zip-daily.bat, which creates a new file for each day it is run; and
  • zip-hourly.bat, which creates a new file for each (even numbered) hour of the day it is run. Use "Zippy.exe HOURLY" in the command line when you use this file.
Whichever one you choose, rename it to zip.bat, or it won't work. The backup files are stored in a "zip" folder
Update: I discovered that Clarion has installed 7z.exe in the Clarion\bin folder, so instead of using pkzipc.exe you can use 7z instead. I have updated the batch files to reflect this.

Backup with every build

If you want to make a backup after every successful build, then there is an additional step you should take:
From the "Project" menu, select "Project Options..." and go to the "Build Events" tab. Use the Ellipsis button to select the Zippy.exe in the same folder as your project. Make sure the post-build event is set to "On Successful Build" so you don't back up a bad set of data. If you do a lot of builds in a day, then it may be a backup too often. The Developer Team template makes a backup before the build, and it gives each backup a sequential number, so you can work backwards if needed. Or you can do both.

Another Option: Batch file

Carl Barnes told me of his solution: a single batch file that you copy and modify for each project. It uses RoboCopy and PowerShell to do some of the heavy lifting. These are included in Windows, so no extra installation required. He has shared it on GitHub. He offers various options, including a batch file that copies all your stuff to another drive. Worth checking out.
He also includes another batch file contributed by Rich Fulham during a ClarionLive webinar, which uses 7-Zip. So there are plenty of options.

Backup to the Cloud or another PC

Making zip copies of the project is a good way to keep a timeline, but if your hard drive crashes, you don't have a backup. A backup is only a backup if you have two other copies of the file, one on another media like a CD ROM or external hard drive (try SyncTrayzor or FreeFileSync), and one in the cloud or offline storage somewhere. Something like Google Drive, Dropbox, iDrive, Carbonite, etc.



Update Tuesday 2 October 2023: Newer version of Zippy.exe which allows you to kill or run applications using a file called zippy.ini in the same folder as zippy.exe. The file structure is simple. Each program you may want to run starts on a line by itself:
run="C:\Program Files (x86)\DebugView++\DebugView++.exe"
and each program/process to kill is just on a line without anything further:
iexplorer.exe
Use this in conjunction with the Clarion Build Events technique. You can automatically stop and start the debug program when you build your app.

No comments: