Size limited repository

Do you have some script for Windows or Linux to remove older snapshots to keep repository size in limit on storage?

I like to have backups limited to size of repository.

This part will mean something different depending on user requirement - not easy to come up with universal solution especially when multiple clients backup to the same repo.

I think the easiest what you could do is to make restic backup run dependent on all repo size condition and if above specified limit notify you and let you decide how to prune repo size - delete oldest backups, change forget settings etc.

I would use rclone size remote:path/to/repo/dir to calculate repo size - it will simply let you know how big repo directory is and supports any cloud storage restic supports. Also it will be many times faster that using restic to calculate repo size.

In pseudo code:

size = $(rclone size remote:path/to/repo/dir)
size_limit=N

if size < size_limit then
  restic backup
else
  notify user - send email or similar
fi

all together it will be few lines script.

When you adjust forget settings after first or second alert you should most likely never see size error again and sill have a safety mechanism in place to prevent repo from growing without limits.

1 Like