Feature: Backup and versioning (--backup, --backup-dir, --suffix) #178

Closed
opened 2026-07-30 18:32:17 +02:00 by TapTap · 0 comments
Owner

Corresponding rsync flags/behavior:

  • --backup — make backups of files that are about to be replaced or deleted
  • --backup-dir=DIR — put backups into a separate directory hierarchy
  • --suffix=SUFFIX — backup filename suffix (default ~)

Current FastSync behavior:
There is no backup support. When --delete removes a file or an incremental transfer overwrites an existing file, the old version is lost permanently.

Proposed changes:

  • CLI flags: --backup, --backup-dir=<dir>, --suffix=<suffix>
  • Config fields: bool use_backup, char* backup_dir, char* backup_suffix
  • Implementation:
    • Before overwriting or deleting an existing destination file, rename it to <path><suffix> or move it to <backup-dir>/<relative-path><suffix>
    • Create backup directory tree as needed
    • Avoid backing up files that are already backups
  • Protocol: no wire changes; receiver performs backups before applying changes

Priority: medium
Rationale: Backups are critical for safe synchronization, especially when --delete is used. Users need a safety net against accidental data loss.

Acceptance criteria:

  • --backup creates file.txt~ before overwriting file.txt
  • --backup-dir=backups moves old versions into backups/<relative-path>~
  • --suffix=.bak changes the backup suffix
  • Works for both --delete removals and incremental overwrites
  • Integration tests verify backup creation and content
**Corresponding rsync flags/behavior:** - `--backup` — make backups of files that are about to be replaced or deleted - `--backup-dir=DIR` — put backups into a separate directory hierarchy - `--suffix=SUFFIX` — backup filename suffix (default `~`) **Current FastSync behavior:** There is no backup support. When `--delete` removes a file or an incremental transfer overwrites an existing file, the old version is lost permanently. **Proposed changes:** - CLI flags: `--backup`, `--backup-dir=<dir>`, `--suffix=<suffix>` - Config fields: `bool use_backup`, `char* backup_dir`, `char* backup_suffix` - Implementation: - Before overwriting or deleting an existing destination file, rename it to `<path><suffix>` or move it to `<backup-dir>/<relative-path><suffix>` - Create backup directory tree as needed - Avoid backing up files that are already backups - Protocol: no wire changes; receiver performs backups before applying changes **Priority:** medium **Rationale:** Backups are critical for safe synchronization, especially when `--delete` is used. Users need a safety net against accidental data loss. **Acceptance criteria:** - [ ] `--backup` creates `file.txt~` before overwriting `file.txt` - [ ] `--backup-dir=backups` moves old versions into `backups/<relative-path>~` - [ ] `--suffix=.bak` changes the backup suffix - [ ] Works for both `--delete` removals and incremental overwrites - [ ] Integration tests verify backup creation and content
TapTap added the enhancementneeds-triage labels 2026-07-30 18:32:17 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: TapTap/FastSync#178