Skip to content

ncth/lvm-snp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 

Repository files navigation

lvm-snp

Automatic LVM snapshot management tool

This tool is based on nachoparker/btrfs-snp.

Usage: lvm-snp <src> <vg> (<tag>) (<size>) (<limit>) (<seconds>)

  src     │ create snapshot of the logical volume <src>
  vg      │ virtual group the src is in
  tag     │ name the snapshot <tag>_<timestamp>
  size    | storage size allocated to the snapshot
  limit   │ keep <limit> snapshots with this tag. 0 to disable
  seconds │ don't create snapshots before <seconds> have passed from last with this tag. 0 to disable

Examples

Manual

Snapshot of data in vg00

# lvm-snp data vg00

Tagged snapshot of files in vg00

# lvm-snp data vg00 preupgrade

Tagged snapshot of files in vg00 with size 15gb, but keep maximum 10

# lvm-snp data vg00 preupgrade 15 10

Cron

Hourly snapshot for one day, daily for one week, weekly for one month, and monthly for one year.

cat > /etc/cron.hourly/$BIN <<EOF
  #!/bin/bash
  /usr/local/sbin/lvm-snp data vg00 hourly 1  24 3600
  /usr/local/sbin/lvm-snp data vg00 daily  3  7 86400
  /usr/local/sbin/lvm-snp data vg00 weekly 7  4 604800
  /usr/local/sbin/lvm-snp data bg00 monthly 15 12 2592000
  EOF
  chmod +x /etc/cron.hourly/$BIN"

Installation

sudo wget https://raw.githubusercontent.com/ncth/lvm-snp/master/lvm-snp -O /usr/local/sbin/lvm-snp
sudo chmod +x /usr/local/sbin/lvm-snp

Thinly-provisioned volumes

You can use the lvm-snp-thin script thinly-provisioned volumes. It works like lvm-snp, however there is no size attribute.

Usage: lvm-snp-thin <src> <vg> (<tag>) (<limit>) (<seconds>)
  src     │ create snapshot of the logical volume <src>
  vg      │ virtual group the src is in
  tag     │ name the snapshot <tag>_<timestamp>
  limit   │ keep <limit> snapshots with this tag. 0 to disable
  seconds │ don't create snapshots before <seconds> have passed from last with this tag. 0 to disable

About

Automatic LVM snapshot management tool

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages