backedup

Crates.iobackedup
lib.rsbackedup
version0.1.1
sourcesrc
created_at2021-04-10 18:33:40.498881
updated_at2021-04-12 19:47:38.434539
descriptionA command line util for backup rotation
homepage
repositoryhttps://github.com/bonega/backedup
max_upload_size
id381758
size38,235
Andreas Liljeqvist (bonega)

documentation

README

README

BackedUp

A command line util for backup rotation.

Uses filenames to extract timestamps and then sort files into timeslots for retention or deletion.

Installation

cargo install backedup

A local clone can be built from source and installed with:

cargo install .

Usage

By default, the plan will be displayed. Removal only happens if the --execute flag is given.

Filenames from a given directory are parsed into a time representation.
At least year, month and day have to present to be considered for removal. A configuration of how many files to keep in each slot have to be provided for at least one slot.

The following command will display a plan to keep:

  • one file per year for 20 years
  • one file per month for 12 months
  • one file per day for 30 days
backedup -y 20 -m 12 -d 30 path/to/directory

Files are grouped into separate slots only by time, rest of filename is never considered.
Use --pattern or -p flag if only a specific filename pattern should be accepted.
For example: --pattern '*.log'.

An alternative regex for parsing time from filenames can be provided by --regex. The default is

(?P<year>\d{4}) \D?
(?P<month>\d{2}) \D?
(?P<day>\d{2}) \D?
(
# Optional components.
(?P<hour>\d{2}) \D?
(?P<minute>\d{2}) \D?
(?P<second>\d{2})?
)?

See --help for more details or look at the example config

Logging

By default, file deletion is logged to Syslog

misc

Regex and general inspiration is taken from python-rotate-backups

Commit count: 37

cargo fmt