Giter Club home page Giter Club logo

backme's Introduction

backme --- A backup files organizer

Quite often big files (like database dumps) are backed up on a regular basis. Such backups become a disk space hogs and when time comes to restoring data, it is cumbersome to find the right file for the job. This script checks files of a certain pattern and sorts them by date into daily, monthly, and yearly directories, progressively deleting more and more of the aged files.

Features

Traverses a directory with a huge number of disorganized backup files recursively, deletes unnecessary ones, and packs the rest into a predictable directory structure.

  • Works with multiple backup directories, each of them independent from another.
  • Takes files generated by backups and sorts them either by using yyyy-mm-dd pattern in the files name or by files' modification date. Then picks some files for archiving and deletes other files.
  • It keeps all files from the last 2 days. 1 file per day for the last month, and one file per month afterwards.
  • Files are recognized by a regular expression that matches their name. Each directory can have several regular expressions, and each of them (assuming they do not overlap) is handled separately.

Installation

Download the latest release for your operating system, unzip or untar it, copy backme file to /usr/local/bin or any other directory registered with your $PATH.

Configuration

Create .backme.yml file in your $HOME directory, use a config example to set it up.

The configuration file would look something like this:

---
outputDir: archive
inputDirs:
  - path: /some/dir/to/backup1
    fileRegexPatterns:
      - "^backup"
      - "^local"
  - path: /another/dir/to/backup2
    keepAllFiles: true
    fileRegexPatterns:
      - "\\.dump$"

outputDir : An optional setting (the default is archive). It is the name of the backme's archive directories. They will be placed inside of input directories.

inputDirs : A list of directories where you keep backup files.

inputDirs.path : The path to a backup directory

inputDirs.fileRegexPatterns : A list of regular expression patterns that allow to distinguish one or more series of backup files from other files. All files of such patterns will be used recursively inside of an input directory.

inputDirs.keepAllFiles : An optional boolean parameter (default is false). If true files that would be marked for deletion, will be placed to a delete-me directory.

Finding out the date/time of a backup.

There are two ways to learn when backup is done. First is by modification timestamp. However moving backup to a new directory will reset this timestamp, so it is not a bullet-proof solution.

To get a better experience with partitioning files by time make sure your backup files contain the following pattern in their name that corresponds to the date they were created:

yyyy-mm-dd

For example mybackup-2018-01-02.sql.tar.gz. Otherwise files modification dates will be used instead.

Usage

To check version

backme -v

To organize backups

backme

After backme run the excess of backup files will be deleted, and the rest will spread over an archive directory inside of your backup directory. The structure of the directory is following:

archive
  recent
  last-month
  2015
  2016
  2017
  2018

recent : files from the last 2 days. All existing files from this period are preserved.

last-month : files from the last 31 day, only one file per day is preserved.

yyyy (2015 for example) : files from a particular year. Only the latest file from each month is preserved

If everything works correctly, make a daily cronjob file that would run backme regularly updating the archive directories.

backme's People

Contributors

dimus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

backme's Issues

As a User I want to keep my settings in a configuration file.

The way it is going to work is by creating a directory within a backup directory and move files into folders.
We need to have a list of directories that would have backup files copied to and the name of backme directories (backme by default), that will keep saved files. The directories to organize would have files
to deal with (one or more) that will be recognized by regular expressions.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.