Archive: backup macro?


backup macro?
How to script a backup? I did a search in this forum and found a few examples, but I couldn't fit them to my case (I'm not a programmer :( ).

I'm trying to make an installer for a game modification. It includes loadsa files (~1000) that goes to various subdirectories in gamedir\data\ .End-user possibly has other mods installed, so my installer must backup files that will be replaced. Problem is, I don't know exactly which files user already has. What macro could do the trick (before overwriting any file, copy/move the original to gamedir\modbckup\ )?


What's wrong with this one:
http://forums.winamp.com/showthread....ghlight=backup
?


You mean dis one?

!macro BackupAndExtract DIR FILE
SetOutPath "$INSTDIR\${DIR}"
IfFileExists "$OUTDIR\${FILE}" 0 +3
CreateDirectory "$INSTDIR\backup\${DIR}"
Rename "$OUTDIR\${FILE}" "$INSTDIR\backup\${DIR}\${FILE}"
File "<insert app dir here>\${DIR}\${FILE}"
!macroend

!insertmacro BackupAndExtract "" "Core.dll"
!insertmacro BackupAndExtract "subfolder" "AnotherDLL.dll"
So I'll have to add manually
!insertmacro BackupAndExtract "subfolder" "file.xxx"
for each of 1000 files? That's nuts!
Or is there some other way?

PS: I'm sorry for being so n00bish, but well, I am n00bie :rolleyes: . Started to use NSIS yesterday. :)

Well, you will, in some way or another, have to tell NSIS to check all the files and backup them if needed. If you don't mind backing up files that might not get overwritten you can just use CopyFiles to copy the entire directory somewhere else. If you want to backup just files that are to be overwritten you will have to write a script that will create another script with all of the File commands in it. You should do this using FindFirst, FindNext, FindClose, FileOpen and FileWrite. You will have to loop through all the files you want to add and write !insertmacro to the new script file for each and every one of them (about 10 lines of a loop, not so hard).

PS: I'm sorry for being so n00bish, but well, I am n00bie. Started to use NSIS yesterday.
That's OK, keep asking until you understand.