Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to specify Backup-ID #30

Merged
merged 3 commits into from
Jul 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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