When running new releases of my installer I would like to make a backup of an existing installation by adding files into a ZIP archive.
Currently, I am able to make a backup of an existing installation by coping the files to my Backup destination. A simplified version of the method I use is as follows:
[Files]
; Copy the contents of Bin folder to Backup folder. Skip if files don’t exist.
Source: {app}\Bin\*; DestDir: {app}\Backup\; \
Flags: createallsubdirs external recursesubdirs uninsneveruninstall skipifsourcedoesntexist;
I would appreciate any ideas how I can zip instead?
you may want to check out LOGAN ISSI : http://members.home.nl/albartus/inno/index.html there are some utils bundled with it.
Another method would be to include a batch file which will carry out the backup steps and then get it to remove itself once complete.
checkout this thread: Batch script to zip all the files without the parent folder
however due to licensing you are not allowed to bundle rar.dll with your app so just apply this method but use a package/dll which can be redistributed.
If you can use VBScript to code a simple wrapper you can also make use of windows built in zip compression.
See how you: Can Windows' built-in ZIP compression be scripted?
I used TLama's suggestion and created my own DLL in Delphi (XE3) that zips a folder.
library MyZipLib;
uses
Winapi.Windows,
System.SysUtils,
System.Zip;
{$R *.res}
function ZipCompressFolder(SourcePath, DestinationPath, ArchiveName : PChar): boolean; stdcall;
begin
//If source folder does not exist then exit without error.
if not DirectoryExists(SourcePath) then
begin
result := true;
exit;
end;
try
result := false;
//Make sure destination path exists
ForceDirectories(DestinationPath);
TZipFile.ZipDirectoryContents(IncludeTrailingPathDelimiter(DestinationPath) + ArchiveName, SourcePath);
result := true;
except
on E : Exception do MessageBox(0, PChar('Error calling function [email protected] with message: ' + E.Message + #13#10 + 'Source: ' + SourcePath + #13#10 + 'Dest: ' + DestinationPath+ #13#10 + 'Archive: ' + ArchiveName), 'MyZipLib.dll Error', MB_OK);
end;
end;
exports ZipCompressFolder;
begin
end.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With