Skip to content

Commit

Permalink
Create directory for local repository for restic init (#199)
Browse files Browse the repository at this point in the history
Signed-off-by: hmsayem <hmsayem@appscode.com>
  • Loading branch information
hmsayem authored Mar 16, 2023
1 parent 4fef7bc commit 1c5d99c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
11 changes: 11 additions & 0 deletions pkg/restic/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,10 @@ func (w *ResticWrapper) repositoryExist() bool {

func (w *ResticWrapper) initRepository() error {
klog.Infoln("Initializing new restic repository in the backend....")
if err := w.createLocalDir(); err != nil {
return err
}

args := w.appendCacheDirFlag([]interface{}{"init"})
args = w.appendCaCertFlag(args)
args = w.appendMaxConnectionsFlag(args)
Expand Down Expand Up @@ -169,6 +173,13 @@ func (w *ResticWrapper) backupFromStdin(options BackupOptions) ([]byte, error) {
return w.run(commands...)
}

func (w *ResticWrapper) createLocalDir() error {
if w.config.Provider == storage.ProviderLocal {
return os.MkdirAll(w.config.Bucket, 0o755)
}
return nil
}

func (w *ResticWrapper) cleanup(retentionPolicy v1alpha1.RetentionPolicy, host string) ([]byte, error) {
klog.Infoln("Cleaning old snapshots according to retention policy")

Expand Down
3 changes: 0 additions & 3 deletions pkg/restic/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,6 @@ func (w *ResticWrapper) setupEnv() error {

case storage.ProviderLocal:
r := w.config.Bucket
if err := os.MkdirAll(r, 0o755); err != nil {
return err
}
w.sh.SetEnv(RESTIC_REPOSITORY, r)

case storage.ProviderS3:
Expand Down

0 comments on commit 1c5d99c

Please sign in to comment.