Removing specific file/directory from all restic snapshots?

Hi!

Is there a possibility of removing some file/directory from all restic backup snapshots as if it had not ever existed without recreating a full backup from scratch?

Basically, I would like to remove items from existing backups, which should not have been ever backed up in the first place.

Hi,

Currently there is no official way to do this.

You can try to compile your own restic binary with this pull request:

But itā€™s better to have backup of whole repo. Itā€™s not widely tested.

1 Like

@jarm0 What problem are you wanting to solve by doing this? The file(s) will only take up the space needed for them once.

@rawtaz as mentioned I would like to remove some files from backup which should not have ever been backed up (sensitive data for example).

3 Likes

ā€¦or when I forget to exclude a .Trash folder over 4 months period, when I finally realize itā€™s been backing up tons of GB of production videos that were never intended to be backup up at all which made it into the repository during their temporary stay in the trash bin. Ahhh!

7 Likes

Has anything changed regarding the original issue of removing some specific file from every snapshot after it has been backed up?

1 Like

I donā€™t think this could be done in restic.

The sensitive data you backed up will only be accessible to you or anyone else who has the password. But regardless, thereā€™s currently no way in restic to remove certain files from existing snapshots.

UPDATE as of restic 0.15.0, released 2023-01-12, this is indeed possible.
See Removing files from snapshots in the Restic documentation.

3 Likes

One question about this, if I would go on to remove a file but the size of this file is not small (Idk if this has anything to do with anything but Iā€™m still clarifying just in case), letā€™s say itā€™s 1GB, and Iā€™m using rclone with cloud repos (I donā€™t know if anyone uses restic + rclone with local repos but who knows), would restic need to download and reupload all the data of all the snapshots (or at least a substantially really big amount of data) to delete the file from history? Iā€™m guessing with local repositories this is not such a big deal because well I/O is much faster and it can modify stuff in place but remote repos are not so was kinda wondering this. Or does restic retrieves and reuploads the least amount of data as possible? Being in this case +/- the size of the file to delete.

would restic need to download and reupload all the data of all the snapshots (or at least a substantially really big amount of data)

good question :slight_smile:

The rewrite command only modified the directory metadata contained in a snapshot. This information may have to be reuploaded, but not the actual file contents.