Skip to content

fix(maintenance): prevent backup source and destination recursion, add dry-run and cleanup trap - #30

Merged
ashishsinghbora merged 1 commit into
mainfrom
fix/backup-safety
Sep 24, 2026
Merged

ashishsinghbora merged 1 commit into
mainfrom
fix/backup-safety

Conversation

@ashishsinghbora

Copy link
Copy Markdown
Owner

Summary

  • Prevented recursive backup bloat when output destination is inside or equal to the source directory (auto-calculates relative path and passes tar --exclude flags).
  • Added -n / --dry-run option to preview planned backup paths and exclusions without creating files.
  • Added EXIT/INT/TERM cleanup trap that automatically deletes corrupted or incomplete archives if tar fails or is interrupted.
  • Validates source path existence and directory type prior to execution, rejecting root / backups without explicit targeting.
  • Safely handles spaces, nested directories, and Unicode characters in file paths.

Verification

  • Tested backup of directory containing spaces, subdirectories, and Unicode characters.
  • Verified nested output directory (backups/) is excluded from the generated archive.
  • Verified dry-run does not write to the filesystem.
  • Verified nonexistent source directories exit non-zero.
  • Verified ShellCheck passes without warnings.
  • Verified test suite passes.

@ashishsinghbora ashishsinghbora left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Code review: verified exclusion logic stops destination directory recursion, tested spaces/Unicode handling, and verified cleanup traps on failure.

@ashishsinghbora
ashishsinghbora merged commit b6f8351 into main Sep 24, 2026
1 check passed
@ashishsinghbora
ashishsinghbora deleted the fix/backup-safety branch September 24, 2026 18:01
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.

1 participant