This repository has been archived on 2024-09-20. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
powershell_backupscript/lib/backupscript-compress.psm1
2021-01-15 12:19:10 +01:00

50 lines
No EOL
1.1 KiB
PowerShell

function Backup-GetModuleInfo {
$local:version = "0.1a"
$local:name = "backup_module-7zip"
Write-Log "INFO" "$name v.$version"
}
function Backup-Create {
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string]
$source,
[Parameter(Mandatory=$True)]
[string]
$dest,
[Parameter(Mandatory=$True)]
[string]
$name,
[Parameter(Mandatory=$false)]
[object]
$options
)
Set-Message "Compression of $source to $dest"
if ( -not (Test-Path "$global:bin_path\7za.exe") ) {
Throw [System.IO.FileNotFoundException]::new("7zip executable not found")
return
}
$zip_opt = ConvertTo-CmdlineOptions $options ""
$zip_opt = -join($zip_opt, " -bb3")
$command = -join($global:bin_path, "/7za.exe", " u"," $zip_opt", " `"$dest", "\", "$name", ".7z`"", " `"$source`"")
Write-Debug "commande : $command"
Invoke-Expression $command | % {
if ($_ -ne "" ){ Set-Message $_ }
}
Set-Message "Compressing $source done"
}
function backup-verify {
Set-Message "Verify zip archive"
}
Export-ModuleMember -Function Backup-Create