Skip to content

Commit

Permalink
[feat] only pull at the remote, init and fix locally (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavyLandman authored Apr 23, 2024
1 parent cb54ded commit 4c39590
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions cmd/backup/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,12 +330,12 @@ func backupServer(backupConfig config.BorgConfig, server config.Server, finished
return
}

err = borg.exec("borg init --encryption=repokey-blake2")
err = borg.execLocal("borg init --encryption=repokey-blake2")
if err != nil {
reInit := false
var initError *ssh.ExitError
var initError *exec.ExitError
if errors.As(err, &initError) {
reInit = initError.ExitStatus() == 2
reInit = initError.ExitCode() == 2
}
if !reInit {
result.Err = fmt.Errorf("creating borg repo: %w", err)
Expand Down Expand Up @@ -363,7 +363,15 @@ func backupServer(backupConfig config.BorgConfig, server config.Server, finished
return
}

err = borg.execLocal("borg prune --lock-wait 600 --stats --keep-daily 7 --keep-weekly 20 --keep-monthly 12 --keep-yearly 15")
err = borg.execLocal("borg check --verbose")

if err != nil {
result.Err = fmt.Errorf("checking borg archive failed: %w", err)
finished <- result
return
}

err = borg.execLocal(fmt.Sprintf("borg prune --lock-wait 600 --stats %s", backupConfig.PruneSetting))

if err != nil {
result.Err = fmt.Errorf("pruning borg archive failed: %w", err)
Expand Down

0 comments on commit 4c39590

Please sign in to comment.