Oh but you should save every 5/10 minutes I hear you say - many times I save more often than that but then you get engrossed in solving a problem and you press apply instead of CTRL-S.
So here is my Fix
1. I still save my project in a dropbox directory
2. I have my time-machine backup which backs up hourly
3. I place the following script in my working stack which backs up OUTSIDE the dropboxfolder onto my machine and an external hard drive
Code: Select all
-- Script Local Variable in main Stack Script
Local snCallNumber
-- Call this in PreOpenStack or OpenStack
-- Should be removed in final Standalone
on AutoSaveStack
if the environment <> "development" then exit AutoSaveStack
-- Mainly when debugging could have multiple pending Autosave messages
-- save this stack every 10 minutes to a dropbox directory
-- First Call asks to save - second call makes the backup
if snCallNumber = 0 then
add 1 to snCallNumber
beep
save this stack
ClearPending("AutoSaveStack")
send AutoSaveStack to me in 15 seconds
exit AutoSaveStack
end if
put zero into snCallNumber
send AutoSaveStack to me in 600 seconds
SaveLocalCopy
end AutoSaveStack
on SaveLocalCopy
local lcSaveDefault, lcBackupPath = "/Volumes/WinMac/lcbackups/"
local lcBackupName, lcCurrentName, lcOriginalFile, lcFileList, lnFileNum, lnNext
local lcNonNumeric = "[ \.\-\\ABCDFEGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz]"
put GetStackPath() & "/" into lcSaveDefault
put the short name of this stack into lcBackupName
put the short name of this stack into lcCurrentName
set the defaultfolder to lcBackupPath
put the files into laFileList
put zero into lnNext
repeat for each line lcLine in laFileList
if offset(lcCurrentName, lcLine) > 0 then
put replacetext(lcLine,lcNonNumeric,"") into lnFileNum
-- Now get the last 4 digits - just in case we have a digit in the name
put char -4 to -1 of lnFileNum into lnFileNum
-- Defensive programming Just in case we have non-numerics left in lnFileNum or a bug in the logic
if lnFileNum is not a number then put 2000 into lnFileNum -- 2000 should be a over a months worth
try
if lnFileNum > lnNext then put lnFileNum into lnNext
catch lcErr
answer lnFileNum & CR & lcErr
put 2000 into lnNext
end try
end if
end repeat
-- Pad with Zeroes so when we sort latest is first
add 1 to lnNext
put format ("%04d", lnNext) into lnNext
put lcBackupPath & the short name of this stack & lnNext into lcBackupName
put ".livecode" after lcBackupName
-- Load the current file on disk as a binary/raw data file
put lcSaveDefault & lcCurrentName & ".livecode" into lcOriginalFile
get url("binfile:" & lcOriginalFile)
if IT is empty then
Answer "Error reading Original Stack : " & lcOriginalFile
end if
-- And save it to a local directory, USB or external drive for ease of access and peace of mind!
put IT into url("binfile:" & lcBackupName)
set the defaultfolder to lcSaveDefault
end SaveLocalCopy
function getStackPath
local lcPath
put the filename of this stack into lcPath
set the itemdel to "/"
-- Delete the filename
delete item - 1 of lcPath
return lcPath
end getStackPath
on ClearPending pMsg
local lcLine
repeat for each line lcLine in the pendingmessages
if pMsg is in item 3 of lcLine then
cancel item 1 of lcLine
end if
end repeat
end ClearPending
This averages about 60+ files in a day which can be removed by hand and the last one renamed with the day when I start again next day. I also rename the stack by adding a letter/word or 2 - so the new file names star again with a 0001 suffix.
This is another defence that means if I accidentally load an old stack while the newest is loaded, worst case Livecode mixes up the library stacks which very rarely change. This only happened once in the early days (purge/cancel??) but others have had the same problems.
So now I have a backup in my dropbox directory , in the dropbox cloud (with untold previous versions), on my main hard disk and my external drive and timemachine.
Any mods, changes, suggestions, greatly appreciated.
As Marvin would say - "Backups? Don't talk to me about Backups!"
With apologies to Douglas Adams.
Regards Lagi
p.s.
Is there a way to get the system to "press" the APPLY Button on the editor?
Oh and yes I know I COULD find the last filename quicker by sort descending (I did at first), but I thought going through all files would be safest ... just in case ... Paranoid Moi??