npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bapuli

v0.0.1

Published

Backup Purging List

Downloads

5

Readme

BaPuLi

Backup Purging List,

Índex

Abstract

Take a list of backup files from stdin and generate a list of those which can be removed according to given rules.

Each argument represents a rule of two time intervals separated by a colon. We will call them age and frequency, respectively:

  • Age: Represents the minimum age of a file (how much time ago) for the rule starting to apply.

  • Frequency: Is the maximum allowed interval between two consecutive preserved (that is: omitted in the output) backups.

Below rules apply too:

  • Oldest file is always kept.

  • All rules apply from the ending date of the next rule to its own. Except last one which apply from the oldest file's date.

  • After the first rule's age, all files are kept.

  • Both intervals sould consist of a number and an unit name (ex: "1year") with no spaces.

    • If number is omitted, then 1 is assumed.
    • If unit is ommitted, then day is assumed.
    • Valid units are below (and in fact any of MomentJS Duration units will work):

| Key | Shorthand | |----------------|-----------| | year(s) | y | | month(s) | M | | week(s) | w | | day(s) | d | | hour(s) | h | | minute(s) | m | | second(s) | s | | millisecond(s) | ms |

File list is read from stdin (one file per row) and it is returned the same way through stdout with kept files being removed so it can be used as input for a deletion process.

  • All file name is supposed to contain a 'YYYYMMDD'-formatted date in its name (first matching pattern will be assumed).

  • Files not following this pattern are ignored (even warning message is send to stderr).

  • File names can contine absolute or relative paths. In this case they will be grouped by its actual path string (so multiple backup lists can be processed at once if required rules are the same).

Compilation

npm run build

You will find binary compiled for your OS under build directory.

Installation

After compiled, take bapuli binary and place a copy of it under a route under your execution path (like /usr/local/bin).

Usage example

    find path/to/my_backups -type f \
      | bapuli 1:1 1week:week 3month:1month 1year:1year 5year:10year \
      | perl -pe 'print "rm "' \
      | bash

This will generate a list of all files under specified directory that can be removed ensuring to keep:

  • All files from up to 1 day before.

  • One file every day from those older than one day ( 1:1 ) up to first week ago (according to next rule).

  • One file per week from first week ( 1week:week ) and up to 3 months old.

  • One file per month from 3 months ago ( 3month:1month )...

  • One file per year from 1 year ago ( 1year:1year )...

  • One file every ten years from 5 years ago ( 5year:10year ).

  • Oldest file.

    • Oldest file is always preserved. In fact all calculations are made from that to current time.

Contributing

If you are interested in contributing with this project, you can do it in many ways:

  • Creating and/or mantainig documentation.

  • Implementing new features or improving code implementation.

  • Reporting bugs and/or fixing it.

  • Sending me any other feedback.

  • Whatever you like...

Please, contact-me, open issues or send pull-requests thought this project GIT repository