MyNixOS website logo
Description

Advanced rotation of backups and other things.

About

frotate stands for "functional rotate", whatever. This is an evolution of the log2rotate's ideas. See also pylog2rotate.

frotate is designed to rotate backups with any balance between retention and space usage. Instead of rotating backups using some familiar method such as daily, weekly, monthly, and yearly periods, it rotates backups using any periods. Thus "functional".

The idea is simple, the rotation schedule is determined by an integer function. This function gives us a period (number) of days when we must encounter at least one backup or whatever we are rotating. When we use an exponential function, the scheme is similar to the radioactive decay law. When the funtion is simply a constant 1, we don't rotate anything and retain all the backups. If it is 2, we retain each second backup. With some trivial function we can achieve a well-known dayly-weekly-monthly-yearly scheme.

The frotate command line utility implements only exponential periods with arbitrary base (ensure it is > 1, or have fun otherwise).

Usage

Note that when neither --keep nor --delete option is given, the utility prints all intervals with all days in them to standard error. In production you will need to specify --keep or --delete explicitly.

Usage: frotate ([-k|--keep] | [-d|--delete]) [-b|--base BASE] DAY...

Available options:
  -k,--keep                Print days to keep
  -d,--delete              Print days to delete
  -b,--base BASE           Base of the exponent (default: 1.1)
  -h,--help                Show this help text

Example

Different modes with the same days:

$ frotate --base 2 2019-08-31 2019-08-30 2019-08-29 2019-08-28 2019-08-27 2019-08-26 2019-08-25 2019-08-24
2019-08-31
2019-08-29 2019-08-30
2019-08-25 2019-08-26 2019-08-27 2019-08-28
2019-08-24

$ frotate --keep --base 2 2019-08-31 2019-08-30 2019-08-29 2019-08-28 2019-08-27 2019-08-26 2019-08-25 2019-08-24
2019-08-31 2019-08-29 2019-08-25 2019-08-24

$ frotate --delete --base 2 2019-08-31 2019-08-30 2019-08-29 2019-08-28 2019-08-27 2019-08-26 2019-08-25 2019-08-24
2019-08-30 2019-08-26 2019-08-27 2019-08-28

More or less realistic example when we keep some backups and get new ones, but not every day:

$ frotate --keep --base 2 2019-09-01 2019-08-31 2019-08-30 2019-08-28 2019-08-24
2019-09-01 2019-08-30 2019-08-28 2019-08-24

$ frotate --keep --base 2 2019-09-05 2019-09-01 2019-08-30 2019-08-28 2019-08-24
2019-09-05 2019-08-30 2019-08-24

$ frotate --keep --base 2 2019-09-06 2019-09-05 2019-08-30 2019-08-24
2019-09-06 2019-09-05 2019-08-24

$ frotate --keep --base 2 2019-09-07 2019-09-06 2019-09-05 2019-08-24
2019-09-07 2019-09-05 2019-08-24

$ frotate --keep --base 2 2019-09-08 2019-09-07 2019-09-06 2019-08-24
2019-09-08 2019-09-06 2019-08-24

$ frotate --keep --base 2 2019-09-09 2019-09-08 2019-09-06 2019-08-24
2019-09-09 2019-09-08 2019-09-06 2019-08-24
Metadata

Version

0.1.1

License

publicDomain

Executables (1)

  • bin/frotate

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows