Page 1 of 1
Backing up a stack; problems with save as
Posted: Wed Nov 04, 2026 11:26 pm
by jimlehrman
I’m wanting to write a script that periodically creates a back up copy of a stack. I want the back up stack to have a unique name that depicts the time it was backed up. But my use of “save as” is not working. I can write scripts that save the stack automatically, but can't get it to save the stack as a separate stack than the original. Can anyone help me with a script that does what I want. Here’s what isn’t working for me:
put "Client Emails BU" && the short date && the time into vBUstack
save this stack as vBUstack
I’ve also tried revSmartSave plugin and it doesn’t seem to do anything. (Maybe it’s too old?)
Thanks for any help on this.
Jimmy
San Diego CA
Paonia CO
Re: Backing up a stack; problems with save as
Posted: Thu Nov 05, 2026 10:14 pm
by scott_morrow
Chipp Walters
https://www.altuit.com/ shared a number of great utilities back in the day. I still use this one regularly.
Code: Select all
--|--------------------------------
--| based on the AltArchive plugin
--|
--| Chipp Walters
--| AltArchive version 1.7
--|--------------------------------
on mouseUp
altShowMe
end mouseUp
on altGetInfo
put fld "info" into tMsg
put "altAnswer " & tMsg into toDo
call toDo of stack "AltPlugin"
end altGetInfo
on altGetVersion
send "altAnswer" && first word of fld "info" to stack "AltPlugin"
end altGetVersion
on openStack
if word 1 of the systemVersion is "NT" and word 2 of the systemVersion > 5 then
put queryRegistry("HKEY_CURRENT_USER\Control Panel\Colors\MenuBar") into tColor
if tColor <> "" then
put word 1 of tColor,word 2 of tColor,word 3 of tColor into tColor
set the backgroundColor of this stack to tColor
end if
end if
end openStack
function checkStyle
if the short name of the topStack = the short name of me then
return true
else
return false
end if
end checkStyle
on altShowMe
if the altKey is down then
if the platform is "Win32" then
put the filename of the topstack into tfile
#replace quote with empty in tfile
replace "/" with "\" in tfile
put "attrib"&& quote & tfile & quote && "-R" into DosCommand
put DosCommand
set the hideConsoleWindows to true
put shell (DosCommand)
answer information tfile & cr & "Unlocked"
end if
exit to top
end if
put the short name of the topStack into StackName
put the mainStack of stack StackName into StackName
if the effective filename of stack StackName is empty then
--> THE STACK HAS NEVER BEEN SAVED
answer question "This stack has never been saved." & cr & "Do you wish to save it now?" with "Cancel" or "Okay"
if it is "Cancel" then exit to top
revSaveAs StackName
else
answer question "Archive Stack: " & StackName with "Cancel" and "Okay"
if it is "Cancel" then exit to top
revSave StackName
end if
put the fileName of stack StackName into StackFileName
put the fileName of stack StackName into folderPath
set itemDel to "/"
put the last item of folderPath into fileName
delete last item of folderPath
put folderPath & "/" into folderPath
set itemDel to "."
if the number of items in fileName > 1 then
delete the last item of fileName
end if
set itemDel to ","
put the defaultFolder into savedDF
set the defaultFolder to folderPath
put the files into fileList
--CHECK TO SEE IF ARCHIVE FOLDER EXISTS
if there is not a folder "archive" then
printMsg "making folder Archive",""
create folder "archive"
end if
put folderpath & "archive/" into folderpath
set the defaultFolder to folderPath
repeat with count = 1 to 1000
if count < 10 then
put fileName & "0000" & count & ".rev" into file2save
else
put fileName & "000" & count & ".rev" into file2save
end if
if there is not a file file2save then
-- IF YOU UNCOMMENT THE BELOW YOU NEED TO COMMENT THESE THREE LINES
put "binfile:" & StackFileName into file2copy
printMsg "File to Copy", StackFileName
put "binfile:" & folderpath & file2save into archiveFile
printMsg "Archive File:" ,folderpath & file2save
put url file2copy into url archiveFile
exit repeat
end if
end repeat
set the defaultFolder to savedDF
end altShowMe
on printMsg msg1 msg2
-- --NEED TO COMMENT OUT WHEN IT'S A PALETTE
-- put msg1 & ":" & msg2 into line (the number of lines of fld "test" of stack "revArchive" + 1) of fld "test" of stack "revArchive"
end printMsg
Re: Backing up a stack; problems with save as
Posted: Fri Nov 06, 2026 5:00 am
by dunbarx
I have never tried this. But a simple handler in a button:
Code: Select all
n mouseUp
save this stack as "backup" & random(99)
end mouseUp
does NOT create a new stack such as "backup32". Not sure why not, but will play with it tomorrow when I get to my office with better tools, and to see if the filePath is being improperly ignored.
Craig
Re: Backing up a stack; problems with save as
Posted: Fri Nov 06, 2026 9:02 am
by SparkOut
Not tested, but I suspect a confusion between the "name" of the stack and the "filename" of the stack.
Re: Backing up a stack; problems with save as
Posted: Fri Nov 06, 2026 12:28 pm
by Klaus
Hi Jim,
you need to create a COPY of the binary stackfile on disk!
Something like this (out of my head):
Code: Select all
command saveAcopy
## IMPORTANT to get an up-to-date set of data!:
save this stack
## To make sure the copy is in the SAME directory as the stack
## Change this if you want to save the copy elsewhere
put specialfolderpath("resources") & "/" into tTargetFolder
put tTargetFolder & "Client Emails BU" && the short date && the time into vBUstack
## Filename of the binary file to copy
put the filename of this stack into tSource
put url("binfile:" & tSource) into url("binfile:" & vBUstack)
## Optional, but you'll need to define an EXIT here:
send "saveAcopy" to me in 60 secs
## or whatever frequnency you prefer
end saveAcopy
HINT:
This will NOT change the NAME of the stack.
Hope that helps!
Best
Klaus