- NSIS Discussion
- Backup before install
Archive: Backup before install
Farewellx
17th March 2009 20:35 UTC
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 =)
Animaether
17th March 2009 21:55 UTC
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 )
Farewellx
17th March 2009 23:12 UTC
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 =)
zeeh3
17th March 2009 23:15 UTC
This macro only works for files, not folders.
Farewellx
17th March 2009 23:17 UTC
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
Farewellx
17th March 2009 23:18 UTC
damn ... this one: nsis.sourceforge.net/Backup_files_on_install,_restore_on_uninstall
thanks =)
zeeh3
17th March 2009 23:54 UTC
Maybe calling SHFileOperation with system plugin can solve the problem.
Animaether
18th March 2009 02:49 UTC
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 :\
TobbeSweden
18th March 2009 08:02 UTC
I don't get it. Why can't you just do something like this?
CopyFiles "C:\folder\*" "C:\folder_backup\"
Animaether
18th March 2009 12:27 UTC
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?
TobbeSweden
18th March 2009 12:32 UTC
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?
Animaether
18th March 2009 12:56 UTC
true that, TobbeSweden; although he didn't specify 'whole' explicitly, I suppose that is indeed all he might need :)
Farewellx
18th March 2009 13:47 UTC
hey guys, yes the installer should copy the hole folder with all the files and subfolders
Farewellx
18th March 2009 13:55 UTC
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 =)
njshaw2
20th March 2009 15:03 UTC
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.
Farewellx
23rd March 2009 00:57 UTC
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