Skip to content

Commit 01b59d7

Browse files
committed
fix: use rustic caching
1 parent 7871cbd commit 01b59d7

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/server/backup/backup_rustic.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,15 @@ func (r *RusticBackup) Details(ctx context.Context, parts []remote.BackupPart) (
550550

551551
// initializeRepository initializes the rustic repository
552552
func (r *RusticBackup) initializeRepository(ctx context.Context) error {
553+
cfg := config.Get().System.Backups.Rustic
554+
555+
// Create cache directory for rustic
556+
repoBasePath := filepath.Dir(cfg.Local.RepositoryPath)
557+
cacheDir := filepath.Join(repoBasePath, "rustic-cache")
558+
559+
if err := os.MkdirAll(cacheDir, 0750); err != nil {
560+
r.log().WithError(err).Warn("failed to create cache directory, caching may not work properly")
561+
}
553562
r.repositoryPath = r.getRepositoryPath()
554563

555564
// Validate repository path
@@ -575,7 +584,6 @@ func (r *RusticBackup) initializeRepository(ctx context.Context) error {
575584
initCtx, cancel := context.WithTimeout(ctx, rusticCommandTimeout)
576585
defer cancel()
577586

578-
cfg := config.Get().System.Backups.Rustic
579587
cmd := r.buildRusticCommandWithContext(initCtx, "init")
580588

581589
if cfg.RepositoryVersion > 0 {
@@ -655,8 +663,10 @@ func (r *RusticBackup) buildRusticCommandWithContext(ctx context.Context, args .
655663
cmd.Env = append(cmd.Env, fmt.Sprintf("RUSTIC_PASSWORD=%s", r.repositoryPassword))
656664
}
657665

658-
// Disable caching for security
659-
cmd.Env = append(cmd.Env, "RUSTIC_NO_CACHE=true")
666+
repoBasePath := filepath.Dir(cfg.Local.RepositoryPath)
667+
cacheDir := filepath.Join(repoBasePath, "rustic-cache")
668+
cmd.Env = append(cmd.Env, fmt.Sprintf("RUSTIC_CACHE_DIR=%s", cacheDir))
669+
r.log().WithField("cache_dir", cacheDir).Debug("rustic caching enabled")
660670

661671
// Set S3 credentials if using S3
662672
if r.backupType == "s3" {

0 commit comments

Comments
 (0)