# rdiff-backup — Incremental Backups with History

> Practical guide to rdiff-backup: mirror plus reverse diffs for incremental backups with version history, locally or over SSH.

Source: https://www.jpkc.com/db/en/cheatsheets/backup-sync/rdiff-backup/

<!-- PROSE:intro -->
rdiff-backup merges two backup approaches into a single tool: the target holds a complete mirror of your latest state, while older versions sit alongside it as space-efficient reverse diffs. That means you can browse the most recent backup like an ordinary file copy and still roll back to any earlier point in time whenever you need to. Backups run locally or over SSH to a remote server – this guide walks you through the key commands, from your first backup to restoring a single file.
<!-- PROSE:intro:end -->

## Create Backups

`rdiff-backup <source> <target>` — Backup a directory (mirror + incremental diffs).

```bash
rdiff-backup /home/user /backup/home
```

`rdiff-backup <source> <user>@<host>::<path>` — Backup to a remote server via SSH.

```bash
rdiff-backup /var/www admin@backup-server::/backup/www
```

`rdiff-backup <user>@<host>::<path> <local>` — Backup from a remote server to local.

```bash
rdiff-backup admin@server::/var/www /backup/www
```

`rdiff-backup --include '<pattern>' --exclude '**' <source> <target>` — Backup only specific directories/files.

```bash
rdiff-backup --include '/home/user/Documents' --include '/home/user/.config' --exclude '**' /home/user /backup/selective
```

`rdiff-backup --exclude '<pattern>' <source> <target>` — Exclude files or directories from backup.

```bash
rdiff-backup --exclude '**/node_modules' --exclude '**/.cache' /home/user /backup/home
```

## Restore

`rdiff-backup --restore-as-of now <backup> <dest>` — Restore the latest version.

```bash
rdiff-backup --restore-as-of now /backup/home /tmp/restore
```

`rdiff-backup --restore-as-of <time> <backup> <dest>` — Restore from a specific point in time.

```bash
rdiff-backup --restore-as-of 3D /backup/home /tmp/restore
```

`rdiff-backup --restore-as-of <time> <backup>/<file> <dest>` — Restore a specific file or directory.

```bash
rdiff-backup --restore-as-of 2D /backup/home/Documents/report.pdf /tmp/report.pdf
```

`rdiff-backup --restore-as-of '2026-03-15' <backup> <dest>` — Restore from a specific date.

```bash
rdiff-backup --restore-as-of '2026-03-15' /backup/www /tmp/www-restore
```

## Time Formats

`now` — Current time (latest backup).

```bash
--restore-as-of now
```

`<n>s / <n>m / <n>h / <n>D / <n>W / <n>M / <n>Y` — Relative time: seconds, minutes, hours, days, weeks, months, years ago.

```bash
--restore-as-of 3D (3 days ago)
```

`YYYY-MM-DD` — Absolute date.

```bash
--restore-as-of 2026-01-15
```

`YYYY-MM-DDTHH:MM:SS` — Absolute date and time.

```bash
--restore-as-of 2026-01-15T14:30:00
```

## Info & Status

`rdiff-backup --list-increments <backup>` — List all available backup increments (restore points).

```bash
rdiff-backup --list-increments /backup/home
```

`rdiff-backup --list-increment-sizes <backup>` — List increments with their sizes.

```bash
rdiff-backup --list-increment-sizes /backup/home
```

`rdiff-backup --list-at-time <time> <backup>` — List files as they were at a specific time.

```bash
rdiff-backup --list-at-time 7D /backup/home
```

`rdiff-backup --list-changed-since <time> <backup>` — List files changed since a specific time.

```bash
rdiff-backup --list-changed-since 1D /backup/home
```

`rdiff-backup --compare <source> <backup>` — Compare source with backup and show differences.

```bash
rdiff-backup --compare /home/user /backup/home
```

`rdiff-backup --compare-at-time <time> <source> <backup>` — Compare source with backup at a specific time.

```bash
rdiff-backup --compare-at-time 1D /home/user /backup/home
```

## Cleanup & Maintenance

`rdiff-backup --remove-older-than <time> <backup>` — Remove increments older than the specified time. **Destructive** – removed older states cannot be recovered.

```bash
rdiff-backup --remove-older-than 90D /backup/home
```

`rdiff-backup --remove-older-than <n>B <backup>` — Keep only the last N backups (this also deletes older states permanently).

```bash
rdiff-backup --remove-older-than 5B /backup/home
```

`rdiff-backup --verify <backup>` — Verify the integrity of the backup repository.

```bash
rdiff-backup --verify /backup/home
```

`rdiff-backup --force --remove-older-than <time> <backup>` — Force removal even if it means removing all increments – use with care.

```bash
rdiff-backup --force --remove-older-than 30D /backup/home
```

## Common Patterns

`rdiff-backup --exclude-globbing-filelist <file> <source> <target>` — Use a file with include/exclude patterns.

```bash
rdiff-backup --exclude-globbing-filelist patterns.txt /home/user /backup/home
```

`rdiff-backup --print-statistics <source> <target>` — Show detailed transfer statistics after backup.

```bash
rdiff-backup --print-statistics /home/user /backup/home
```

`rdiff-backup -v5 <source> <target>` — Run with verbose output (level 0-9).

```bash
rdiff-backup -v5 /home/user /backup/home
```

`rdiff-backup --remote-schema 'ssh -p <port> %s rdiff-backup --server' <source> <user>@<host>::<path>` — Use a custom SSH port for remote backup.

```bash
rdiff-backup --remote-schema 'ssh -p 2222 %s rdiff-backup --server' /data admin@server::/backup/data
```

<!-- PROSE:outro -->
## Conclusion

rdiff-backup is ideal when you want the instant access of a mirror combined with the safety of version history, without setting up a full-blown backup system. Schedule regular cleanup with `--remove-older-than` so increments don't grow without bound – and remember that this step deletes older states permanently. Verify your backups with `--verify` before you have to rely on them in an emergency.

## Further Reading

- [rdiff-backup – official project site](https://rdiff-backup.net/) – documentation, manual and downloads
- [rdiff-backup on GitHub](https://github.com/rdiff-backup/rdiff-backup) – source code, issues and release notes
<!-- PROSE:outro:end -->

## Related Commands

- [borgbackup](https://www.jpkc.com/db/en/cheatsheets/backup-sync/borgbackup/) – deduplicating, compressed and encrypted backups
- [duplicity](https://www.jpkc.com/db/en/cheatsheets/backup-sync/duplicity/) – encrypted incremental backups, including to the cloud
- [rclone](https://www.jpkc.com/db/en/cheatsheets/backup-sync/rclone/) – sync files with cloud storage and between systems

