50 lines
No EOL
1.1 KiB
PowerShell
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 |