Score:1

How to prevent rdiff-backup from deleting files?

cn flag

I am using rdiff-backup to back up my data (on Ubuntu 20.04), which works quite smoothly - and I appreciate the incremental backup, keeping the data easily accessible.

However, since my internal hard drive is quite small, I would sometimes like to remove things after I have backed them up to the external backup drive. But that makes rdiff-backup remove it from the backup drive next time it is synced. Is there some way to prevent rdiff-backup from deleting previously backed up files that no longer exist on the source drive?

Score:1
jp flag

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

sdbbs avatar
id flag
I need the same OP needs - as far as I can tell, rdiff-backup also can rotate the snapshots, which means at a certain point, the deleted file will truely be gone. One would have wished, given that deletion is a default, to have a `--no-delete` argument (in which case we'd have just copying), but apparently, there no such option... (and for some reason, I cannot make an exclude filter, that will ignore wanting to delete files)
Andrew Lowther avatar
jp flag
@sdbbs the backups are kept until you run `rdiff-backup --remove-older`. If you delete the original file *and* you delete all the backups that contain the original file; then the original file will be gone. I'm not sure how else you would want it to work. Maybe you can create a new question giving an example of your issue.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.