First commit
This commit is contained in:
commit
cce27559b1
9 changed files with 676 additions and 0 deletions
46
lib/backupscript-clone.psm1
Normal file
46
lib/backupscript-clone.psm1
Normal file
|
@ -0,0 +1,46 @@
|
|||
function Backup-Create () {
|
||||
Param(
|
||||
[Parameter(Mandatory=$True)]
|
||||
[string]
|
||||
$source,
|
||||
[Parameter(Mandatory=$True)]
|
||||
[string]
|
||||
$dest,
|
||||
[Parameter(Mandatory=$false)]
|
||||
[string]
|
||||
$name,
|
||||
[Parameter(Mandatory=$false)]
|
||||
[object]
|
||||
$options
|
||||
)
|
||||
|
||||
$copy_opt = "--stats=0 --log-level INFO --log-format `"shorfile`" "
|
||||
Set-Message "Sync files from $source to $dest"
|
||||
|
||||
if ( -not (Test-Path "$global:bin_path\rclone.exe") ) {
|
||||
Throw "Rclone executable not found"
|
||||
}
|
||||
$copy_opt = -join($copy_opt, $(ConvertTo-CmdlineOptions $options))
|
||||
$command = -join($global:bin_path, "\rclone.exe", " sync", " `"$source`"", " `"$dest`"", " $copy_opt", " 2>&1")
|
||||
Set-Message "$command"
|
||||
Invoke-Expression $command -ErrorAction Ignore | % {
|
||||
if ($_ -ne ""){
|
||||
$type, $mdg = ($_ -split ':')[0]
|
||||
$msg = -join ($_ -split ':')[1..2]
|
||||
|
||||
switch ( $type.trim() ){
|
||||
"INFO" {
|
||||
Set-Message $msg.trim()
|
||||
}
|
||||
"WARN" {
|
||||
Set-Warning $msg.trim()
|
||||
}
|
||||
"ERROR" {
|
||||
Set-Error $msg.trim()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Export-ModuleMember -Function Backup-Create
|
Reference in a new issue