First commit
This commit is contained in:
commit
cce27559b1
9 changed files with 676 additions and 0 deletions
50
lib/backupscript-compress.psm1
Normal file
50
lib/backupscript-compress.psm1
Normal file
|
@ -0,0 +1,50 @@
|
|||
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
|
Reference in a new issue