fix local kopia strategy
This commit is contained in:
parent
1946692f17
commit
f531edb440
@ -60,7 +60,7 @@ func (f *Factory) createKopiaStrategy(serviceConfig *models.BackupConfig, source
|
|||||||
func (f *Factory) createKopiaProvider(strategyConfig models.StrategyConfig) (kopia.Provider, error) {
|
func (f *Factory) createKopiaProvider(strategyConfig models.StrategyConfig) (kopia.Provider, error) {
|
||||||
switch strategyConfig.Provider {
|
switch strategyConfig.Provider {
|
||||||
case "local":
|
case "local":
|
||||||
return kopia.NewLocalProvider(getDefaultPath(strategyConfig.Destination.Path)), nil
|
return kopia.NewLocalProvider(strategyConfig.Destination.Path), nil
|
||||||
case "b2", "backblaze":
|
case "b2", "backblaze":
|
||||||
return kopia.NewB2Provider(), nil
|
return kopia.NewB2Provider(), nil
|
||||||
case "sftp":
|
case "sftp":
|
||||||
@ -74,15 +74,6 @@ func (f *Factory) createKopiaProvider(strategyConfig models.StrategyConfig) (kop
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// getDefaultPath returns the given path or a default
|
|
||||||
func getDefaultPath(path string) string {
|
|
||||||
if path != "" {
|
|
||||||
return path
|
|
||||||
}
|
|
||||||
home, _ := os.UserHomeDir()
|
|
||||||
return filepath.Join(home, ".backea", "repos")
|
|
||||||
}
|
|
||||||
|
|
||||||
// getServicePath returns a service's path
|
// getServicePath returns a service's path
|
||||||
func (f *Factory) getServicePath(groupName string) (string, error) {
|
func (f *Factory) getServicePath(groupName string) (string, error) {
|
||||||
if serviceGroup, exists := f.Config.Services[groupName]; exists {
|
if serviceGroup, exists := f.Config.Services[groupName]; exists {
|
||||||
|
@ -30,7 +30,6 @@ func (p *LocalProvider) Connect(ctx context.Context, serviceName string, passwor
|
|||||||
repoPath := filepath.Join(p.BasePath, serviceName)
|
repoPath := filepath.Join(p.BasePath, serviceName)
|
||||||
log.Printf("Connecting to local repository at %s with config: %s", repoPath, configPath)
|
log.Printf("Connecting to local repository at %s with config: %s", repoPath, configPath)
|
||||||
|
|
||||||
// Ensure the directory exists
|
|
||||||
if err := os.MkdirAll(repoPath, 0755); err != nil {
|
if err := os.MkdirAll(repoPath, 0755); err != nil {
|
||||||
return fmt.Errorf("failed to create repository directory: %w", err)
|
return fmt.Errorf("failed to create repository directory: %w", err)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user