Code Monkey home page Code Monkey logo

lvm-autosnap's Introduction

lvm-autosnap

Introduction

lvm-autosnap takes and maintains a periodic series of lvm snapshots for an arbitrary logical volume ##

About

Yet another BASH script to take lvm snapshots? Yes, indeed, but it's written to try to overcome the fragility of a script that parses command line output then breaks in weird and wonderful ways. So, instead of messing around with parsing dates and trying to do maths in BASH, we simply ask lvm to do it for us. Shocking eh?

The other big difference is that although the snapshots are dated using an ISO-86-1 format, it's the metadata creation date that is used for processing, not the filename. The advantage here is that one can rename the snapshots if desired, yet they will still process as normal.

A further difference is that lvm-autosnap snapshots are identified by a metadata tag, causing lvm-autosnap to be immune from filename changes. Thus, one can simply remove the tag lvchange --deltag autosnap <vg>/<snapshot> to allow the snapshot to remain, if needed, for posterity. Likewise, a tag can be added to a snapshot lvchange --addtag autosnap <vg>/<snapshot> to add it to the pool of snapshots considered by lvm-autosnap.

Usage

lvm-autosnap --vg=<vg> --lv=<lv> [optional parameters]

Required parameters

  • -g | --vg

    The logical volume group

  • -l | --lv

    The logical volume name

Optional parameters

  • -h | --help

    Hi there!

  • -d | --dry-run

    List commands, do not commit changes

  • -k | --keep-time

    Retention period in "keep-units". Default=days

  • -m | --max-daily

    Maximum number of snaphots allowed per day, Default=5

  • -s | --size

    Snapshot size. default=2G

  • -t | --tag

    Tag to be applied to snapshots. Default=autosnap

  • -u | --keep-units

    Retention period (see keep-units). Default=8

Examples

  • lvm-autosnap --vg=mv_vg --lv=my_lv

    take an autosnap of mv_vg/my_lv, prune using the default retention period of 8 days

  • lvm-autosnap --vg=mv_vg --lv=my_lv --size=4G

    take a 4G autosnap of mv_vg/my_lv, prune using the default retention period of 8 days

  • lvm-autosnap --dry-run --vg=mv_vg --lv=my_lv --keep-time=1 --keep_units=hour

    SIMULATE an autosnap of mv_vg/my_lv, with pruning of other autosnaps older than one hour

Installation

  • Copy the lvm-autosnap executable to the directory of your choice.
    • cp lvm-autosnap /usr/local/sbin/.
  • Make it executable
    • chmod 755 /usr/loca/sbin/lvm-autosnap
  • Copy and amend the setting for logrotate and cron
    • cp etc/logrotate.d/lvm-autosnap /etc/logrotate.d/.
    • cp etc/cron.daily/lvm-autosnap /etc/cron.daily/.
  • Additionally, pay attention to the follow settings in /etc/lvm/lvm.conf
    • snapshot_autoextend_threshold
    • snapshot_autoextend_percent
    • thin_pool_autoextend_threshold
    • thin_pool_autoextend_percent

Have fun -- aj

lvm-autosnap's People

Contributors

ajayjay0 avatar poelzi avatar

Watchers

 avatar

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.