Skip to content

Commit

Permalink
revert sftp snapshot
Browse files Browse the repository at this point in the history
  • Loading branch information
Son Roy Almerol committed Dec 9, 2024
1 parent 59f50c2 commit d8833e1
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 97 deletions.
15 changes: 1 addition & 14 deletions internal/agent/sftp/sftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,19 +130,6 @@ func handleRequests(ctx context.Context, requests <-chan *ssh.Request, sftpReque
case "ping":
sftpRequest <- false
req.Reply(true, []byte("pong"))
case "snapshot":
sftpRequest <- false
driveLetter := string(req.Payload[1:])
if driveLetter != "" {
_, err := snapshots.Snapshot(driveLetter, true)
if err != nil {
req.Reply(false, []byte(fmt.Sprintf("failed to initialize snapshot: %v", err)))
return
}
req.Reply(true, []byte("success"))
} else {
req.Reply(false, nil)
}
default:
sftpRequest <- false
req.Reply(false, nil)
Expand All @@ -156,7 +143,7 @@ func handleRequests(ctx context.Context, requests <-chan *ssh.Request, sftpReque
func handleSFTP(ctx context.Context, errChan chan string, channel ssh.Channel, driveLetter string) {
defer channel.Close()

snapshot, err := snapshots.Snapshot(driveLetter, false)
snapshot, err := snapshots.Snapshot(driveLetter)
if err != nil {
errChan <- fmt.Sprintf("failed to initialize snapshot: %v", err)
return
Expand Down
4 changes: 2 additions & 2 deletions internal/agent/snapshots/windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func getVSSFolder() (string, error) {
return configBasePath, nil
}

func Snapshot(driveLetter string, forceNew bool) (*WinVSSSnapshot, error) {
func Snapshot(driveLetter string) (*WinVSSSnapshot, error) {
knownSnaps := &KnownSnapshots{registry: "KnownSnaps"}
volName := filepath.VolumeName(fmt.Sprintf("%s:", driveLetter))

Expand All @@ -40,7 +40,7 @@ func Snapshot(driveLetter string, forceNew bool) (*WinVSSSnapshot, error) {
snapshotPath := filepath.Join(vssFolder, driveLetter)
if knownSnap, err := knownSnaps.Get(snapshotPath); err == nil {
if _, err := vss.Get(snapshotPath); err == nil {
if time.Since(knownSnap.GetTimestamp()) < 15*time.Minute && !forceNew {
if time.Since(knownSnap.GetTimestamp()) < 2*time.Minute {
return knownSnap, nil
}
}
Expand Down
19 changes: 0 additions & 19 deletions internal/backend/backup/jobrun.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,25 +130,6 @@ func RunBackup(job *store.Job, storeInstance *store.Store, waitChan chan struct{

_ = FixDatastore(job, storeInstance)

if isAgent {
snapOk, err := storeInstance.AgentSnapshot(target)
if err != nil {
if agentMount != nil {
agentMount.Unmount()
}
cancel()
return nil, fmt.Errorf("RunBackup: agent snapshot error -> %w", err)
}

if !snapOk {
if agentMount != nil {
agentMount.Unmount()
}
cancel()
return nil, fmt.Errorf("RunBackup: agent snapshot error")
}
}

cmd := exec.Command("/usr/bin/proxmox-backup-client", cmdArgs...)
cmd.Env = os.Environ()
cmd.Env = append(cmd.Env, fmt.Sprintf("PBS_PASSWORD=%s", storeInstance.APIToken.Value))
Expand Down
62 changes: 0 additions & 62 deletions internal/store/snapshot.go

This file was deleted.

0 comments on commit d8833e1

Please sign in to comment.