Archive: Backup before install


Backup before install
hey guys,

need help, i´m trying to make a script which does a backup of the directory like c:\test to c:\testbackup, it should do that automaticly and it should pop up a confirmation ... all that should happen before it starts to install my files, which are in an zip file.... is that possible?

thanks =)




p.s. excuse me for my poor english, my german is much better =)


yes - it's possible
no - it's not easy

one solution...
1. extract all folders and files to a temp location (not in $TEMP, lest that gets auto-cleared)
2. loop over those folders and files (several functions available)
3. check if a given file already exists in the destination folder
4. if it does, rename that file to a backup location
5. then rename the file from your temp location to the destination location

There's others, but the above is reasonably easy to execute :|

( like I mentioned in another thread.. a callback for File/etc. would be awesome )


so there is no way to do that directly, click a button and the given folder copies to the backup folder?
i found this link http://nsis.sourceforge.net/Backup_f...e_on_uninstall but i really don´t know how to import this macro to nsis

!insertmacro BackupFile "Dir with file in it" "File" "Backup to"

lilke: !insertmacro BackupFile "c:\test" "Backup to" "c:\test\backup"

thanks =)


This macro only works for files, not folders.


the link is shown as "URL submitted by user" hope you can see it anyway...

if not here it is insis.sourceforge.net/Backup_files_on_install,_restore_on_uninstall


damn ... this one: nsis.sourceforge.net/Backup_files_on_install,_restore_on_uninstall

thanks =)


Maybe calling SHFileOperation with system plugin can solve the problem.


well, the main problem with most of these headers is that you have to explicitly name every file.

So if you use a File command that includes multiple files (for example, you have a folder called "documentation", and within it is a few hundred html+jpg+gif images as your docs, and you include it as 'File "documentation\*.*"'), you're SOL.

You'd have to first build an include file using another installer that actually grabs the list of files that would be included, and spits out separate File (or in this case BackupFile) commands.

Absolutely doable.. and absolutely annoying :\


I don't get it. Why can't you just do something like this?

CopyFiles "C:\folder\*" "C:\folder_backup\"

Typically because you don't want to back up -all- files - just the ones you're updating/overwriting. E.g. say you're writing a mod for a game that replaces some of the model, graphics and sound files. Do you then want to back up all 7GB, even if you're only replacing, say, 200MB?


Yes of course I understand that there is a need for something like that too, but didn't Farewellx specifically say he wanted to copy a whole directory to a backup location? Or did I misread that?


true that, TobbeSweden; although he didn't specify 'whole' explicitly, I suppose that is indeed all he might need :)


hey guys, yes the installer should copy the hole folder with all the files and subfolders


hey guys, sry for the double post again...

i wouldn´t need an nsis script if it would be possible to click the installer:
1. run my .BAT file which copies the folder/files/subf. to the right destination
2. and after that the the installer actually starts the installing process ...

this would also solve my problem

thx =)


Couldn't you just use NSIS' "Rename" function? That can rename a directory to another name (on the same drive), e.g.:

Rename "C:\test" "C:\testbackup"

That would do the job, providing you wanted the entire folder contents (including sub-folders) moved.


the user must choose the folder before rename it or what ever ... thats what i am looking for ... user chooses the folder, clicks NEXT and the installer renames the folder automaticly to _backup