How to prevent rdiff-backup from deleting files?

If you delete a file then rdiff-backup does not delete the file from the backups. The deleted file won't appear in the Current mirror after the next backup is run, but it is still available to restore.

Here is a basic example.

  • create a directory with the files A.txt and B.txt to be backed up.
root@ubuntu:~# mkdir orig
root@ubuntu:~# uuidgen > orig/A.txt
root@ubuntu:~# uuidgen > orig/B.txt
  • backup the directory with rdiff-backup
root@ubuntu:~# mkdir backup
root@ubuntu:~# rdiff-backup orig/ backup/
  • delete the file A.txt from the original directory and perform a backup.
root@ubuntu:~# rm orig/A.txt
root@ubuntu:~# rdiff-backup orig/ backup/
  • the file A.txt is no longer in the backup directory, but that only represents the Current mirror.
root@ubuntu:~# ls backup/
B.txt  rdiff-backup-data
root@ubuntu:~# rdiff-backup -l backup/
Found 1 increments:
    increments.2021-11-03T21:51:38Z.dir   Wed Nov  3 21:51:38 2021
Current mirror: Wed Nov  3 21:52:08 2021
  • restore the directory from the previous increment 2021-11-03T21:51:38Z and the file A.txt will be restored.
root@ubuntu:~# mkdir restore
root@ubuntu:~# rdiff-backup -r 2021-11-03T21:51:38Z backup/ restore/
root@ubuntu:~# ls restore/
A.txt  B.txt
  • you can also do things like list the files available in a specific increment
root@ubuntu:~# rdiff-backup --list-at-time 2021-11-03T21:51:38Z backup/
.
A.txt
B.txt

Links

  • https://rdiff-backup.net/docs/examples.html
  • http://manpages.ubuntu.com/manpages/focal/en/man1/rdiff-backup.1.html