Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exclude If Present #2016

Merged
merged 13 commits into from
Jun 28, 2024
Merged

Conversation

shivansh02
Copy link
Collaborator

@shivansh02 shivansh02 commented Jun 6, 2024

Description

Exclude directories where specified files are present.

Related Issue

#1863

Motivation and Context

How Has This Been Tested?

Tested manually by running backups. Selected filenames get appended to borg create command as "--exclude-if-present filename". Modified test_exclusion_preview_populated to test preview tab.

Screenshots (if appropriate):

Screenshot from 2024-06-12 18-47-02
Screenshot from 2024-06-12 18-47-08

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • I have read the CONTRIBUTING guide.
  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

I provide my contribution under the terms of the license of this repository and I affirm the Developer Certificate of Origin.

@shivansh02 shivansh02 marked this pull request as draft June 6, 2024 13:28
@shivansh02 shivansh02 marked this pull request as ready for review June 12, 2024 13:15
@shivansh02 shivansh02 requested a review from m3nu June 12, 2024 13:21
@m3nu m3nu force-pushed the exclusions-tab-enhancements branch from a28d690 to 56d5e81 Compare June 12, 2024 15:45
@m3nu
Copy link
Contributor

m3nu commented Jun 12, 2024

Testing this locally now. In the future, you can also rebase a new PR if there were commits in the meantime.

@m3nu
Copy link
Contributor

m3nu commented Jun 13, 2024

Works as expected locally and passes the correct args to Borg.

I would still suggest to add some common example files in the dialog, but keep them unselected. Like the ones shown in Borg's docs.

@shivansh02
Copy link
Collaborator Author

I would still suggest to add some common example files in the dialog, but keep them unselected. Like the ones shown in Borg's docs.

I added two files (.nobackup and .vortaignore). Did these not show up for you?
I added the files as default value for exclude_if_present field in models.py and wrote a migration for the same. Did I miss something?

@@ -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)
exclude_if_present = pw.TextField(null=True, default="[] .nobackup\n[] .vortaignore")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.nobackup is fine, but I wouldn't introduce a new standard, like .vortaignore. Why not add CACHEDIR.TAG, which is an existing standard to support the related Borg flag.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wasn't aware about CACHEDIR.TAG, added it now.

migrator.add_column_default(
BackupProfileModel._meta.table_name,
'exclude_if_present',
pw.TextField(default="[] .nobackup\n[] .vortaignore"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See related comment for model

@@ -137,6 +177,7 @@
</item>
</layout>
</widget>

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we adding a new line here?

@shivansh02 shivansh02 force-pushed the exclusions-tab-enhancements branch from 56d5e81 to 26bb119 Compare June 24, 2024 06:09
@shivansh02 shivansh02 force-pushed the exclusions-tab-enhancements branch from cb3bec4 to 898dea1 Compare June 24, 2024 07:17
@shivansh02 shivansh02 requested a review from m3nu June 24, 2024 07:19
@@ -250,6 +250,17 @@ def run_migrations(current_schema, db_connection):
),
)

if current_schema.version < 23:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe we don't need a migration here, since the default comes from models.py. This also avoids duplicating the same content.

else:
item.setText(pattern)
item.setCheckable(True)
item.setCheckState(Qt.CheckState.Unchecked)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't this mean that all existing exclude settings the user had are now disabled?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@m3nu That's true, I didn't take the existing ones into account. Should I try to make them checked by default?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I would check them by default.

@shivansh02 shivansh02 requested a review from m3nu June 27, 2024 15:17
@m3nu
Copy link
Contributor

m3nu commented Jun 27, 2024

I think we're good now. Let me run it again locally tonight.

@m3nu m3nu merged commit 7ab769e into borgbase:master Jun 28, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants