Skip to content

Commit

Permalink
exclude multiple files
Browse files Browse the repository at this point in the history
  • Loading branch information
shivansh02 committed Jun 24, 2024
1 parent c29a9c3 commit 26bb119
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/vorta/borg/create.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ def prepare(cls, profile):
if f.startswith('[x]'):
patterns.append(f[3:].strip()) # Remove the '[x]' prefix

if patterns:
cmd.extend(['--exclude-if-present'] + patterns)
for pattern in patterns:
cmd.extend(['--exclude-if-present', pattern])

# Add excludes
# Partly inspired by borgmatic/borgmatic/borg/create.py
Expand Down
2 changes: 1 addition & 1 deletion src/vorta/store/migrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ def run_migrations(current_schema, db_connection):
migrator.add_column_default(
BackupProfileModel._meta.table_name,
'exclude_if_present',
pw.TextField(default=".nobackup .vortaignore"),
pw.TextField(default="[] .nobackup\n[] .vortaignore"),
),
)

Expand Down
2 changes: 1 addition & 1 deletion src/vorta/store/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class BackupProfileModel(BaseModel):
ssh_key = pw.CharField(default=None, null=True)
compression = pw.CharField(default='lz4')
exclude_patterns = pw.TextField(null=True)
exclude_if_present = pw.TextField(null=True, default=".nobackup .vortaignore")
exclude_if_present = pw.TextField(null=True, default="[] .nobackup\n[] .vortaignore")
schedule_mode = pw.CharField(default='off')
schedule_interval_count = pw.IntegerField(default=3)
schedule_interval_unit = pw.CharField(default='hours')
Expand Down
12 changes: 11 additions & 1 deletion src/vorta/views/exclude_dialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,18 @@ def save_exclude_if_present_patterns(self):
patterns = []
for row in range(self.excludeIfPresentModel.rowCount()):
item = self.excludeIfPresentModel.item(row)
text = item.text().strip()

# Remove any existing prefix
if text.startswith('[x] '):
text = text[4:]
elif text.startswith('[] '):
text = text[3:]

# Add the correct prefix based on the check state
prefix = '[x] ' if item.checkState() == Qt.CheckState.Checked else '[] '
patterns.append(prefix + item.text())
patterns.append(prefix + text)

self.profile.exclude_if_present = '\n'.join(patterns)
self.profile.save()
self.populate_preview_tab()
Expand Down

0 comments on commit 26bb119

Please sign in to comment.