Skip to content
⌘ NSIS Forum Archive

Best way to do a backup file

5 posts

kike_velez#

Best way to do a backup file

Hello

Before processing a file I want to do a backup of it.
I think about copyfiles

copyfiles myfile myfile.bak

It is the best way ?

Thanks a lot
Yathosho#
i'd add an iffileexist dialog and a messagebox which would ask the user, if he wants to overwrite a previous backup file.
kike_velez#
Hello Yathosho and thanks with reply

But how do you do the backup of the file before processing?

Thanks
Afrow UK#
CopyFiles?
CreateDirectory "$INSTDIR\Backup"

SetOutPath $INSTDIR

IfFileExists "$INSTDIR\file.ext" 0 +2
CopyFiles "$INSTDIR\file.ext" "$INSTDIR\Backup\file.ext"

File "file.ext"
File "..."

RMDir "$INSTDIR\Backup" ; remove backup dir if empty
-Stu