Skip to content

Commit

Permalink
Merge pull request #30 from lookup82/Feature_backup-id
Browse files Browse the repository at this point in the history
Add ability to specify Backup-ID
  • Loading branch information
tizbac authored Jul 10, 2024
2 parents da1c05d + d130a81 commit d68e4bf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ proxmoxbackupgo.exe
Datastore name
-namespace string
Namespace (optional)
-backup-id string
Backup ID (optional - if not specified, the hostname is used as the default for host-type backups)
-pxarout string
Output PXAR archive for debug purposes (optional)
-secret string
Expand Down
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ func main() {
secretFlag := flag.String("secret", "", "Secret for authentication")
datastoreFlag := flag.String("datastore", "", "Datastore name")
namespaceFlag := flag.String("namespace", "", "Namespace (optional)")
backupIDFlag := flag.String("backup-id", "", "Backup ID (optional - if not specified, the hostname is used as the default)")
backupSourceDirFlag := flag.String("backupdir", "", "Backup source directory, must not be symlink")
pxarOut := flag.String("pxarout", "", "Output PXAR archive for debug purposes (optional)")

Expand Down Expand Up @@ -101,6 +102,9 @@ func main() {
secret: *secretFlag,
datastore: *datastoreFlag,
namespace: *namespaceFlag,
manifest: BackupManifest{
BackupID: *backupIDFlag,
},
}

backupdir := *backupSourceDirFlag
Expand Down
6 changes: 4 additions & 2 deletions pbsapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,10 @@ func (pbs *PBSClient) Connect(reader bool) {

pbs.manifest.BackupTime = time.Now().Unix()
pbs.manifest.BackupType = "host"
hostname, _ := os.Hostname()
pbs.manifest.BackupID = hostname
if pbs.manifest.BackupID == "" {
hostname, _ := os.Hostname()
pbs.manifest.BackupID = hostname
}
pbs.client = http.Client{
Transport: &http2.Transport{

Expand Down

0 comments on commit d68e4bf

Please sign in to comment.