DEV Community

Cover image for VolBack: Backup tool
JA Proger
JA Proger

Posted on • Edited on

VolBack: Backup tool

Intro

VolBack?
What's it?
I started to think about potential sum of volumes of everyday backups.
Backup is a full copy of the system for a unit of time (UT).
We know that backups is one of the most important part in backend of any computer system.
Nevertheless, we know backups have weaknesses... There's only one — duplication. Funny thing is that duplication in the case of backups is essential.

Math section

Basic case

Imagine we have a CRM, which has a lifetime of 3 days.
We need to backup it each day.

  • Day 1. We added 100 mb
  • Day 2. We added 50 mb
  • Day 3. We added 30 mb

What does it mean?

  • Backup for day 1: 100 mb
  • Backup for day 2: 100 mb + 50 mb =150 MB
  • Backup for day 3: 150 mb + 30 mb =180 MB

Nice!

So the total backup volume will be: 100 mb + 150 mb + 180 mb =430 MB.

To handle this calculations I find a mathematical formula for this process.

Sn=nx1+i=1n1(ni)ai S_n = n \cdot x_1 + \sum_{i=1}^{n-1} (n - i) * a_i

If:

  1. n>1n > 1
  2. a=n1|a| = n - 1
  3. x1>0x_1 > 0
  4. Sn>0S_n > 0

Where:

  • n: quantity of UT (second, hour, day, etc)
  • x1x_1 : initial value of volume at first UT
  • a: array of a values (additions in volume at each IT)

Special cases

There are special cases of backup volume calculations.

  • If n = 1, we don't need a at all. Therefore S1=x1S_1 = x_1
  • If a is absent, so Sn=nx1S_n = n \cdot x_1
  • If a is static, so Sn=nx1+i=1n1(ni)aS_n = n \cdot x_1 + \sum_{i=1}^{n-1} (n-i) \cdot a

Development

I will expand this method in case when we don't know additions' values.

Watch the repository https://github.com/ja-proger/VolBack. Now available on Swift
Write down any ideas in the comments below!

Top comments (0)