Coder Social home page Coder Social logo

alexxlabs / zfs-snapshot-all Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bahamas10/zfs-snapshot-all

0.0 1.0 0.0 7 KB

Recursively snapshot all zpools

Home Page: http://daveeddy.com/2015/12/05/automatic-zfs-snapshots-and-backups/

License: MIT License

Shell 74.00% Makefile 26.00%

zfs-snapshot-all's Introduction

ZFS Snapshot All

Recursively snapshot all zpools

Examples

Snapshot all zpools with the prefix "foo"

# ./zfs-snapshot-all foo
zfs snapshot -r goliath@foo_1448256528
zfs snapshot -r zones@foo_1448256528

Snapshot all zpools with the prefix "bar" without actually executing any snapshot commands (dry-run)

# ./zfs-snapshot-all -n bar
zfs snapshot -r goliath@bar_1448256538 # dry-run: no action taken
zfs snapshot -r zones@bar_1448256538 # dry-run: no action taken

Snapshot the pools given as arguments, "goliath", "zones", and "fake" with the prefix "foo"

# ./zfs-snapshot-all foo goliath zones fake
zfs snapshot -r goliath@foo_1448256549
zfs snapshot -r zones@foo_1448256549
zfs snapshot -r fake@foo_1448256549
cannot open 'fake': dataset does not exist
# echo $?
1

This script can be best used with cron for automated snapshots

1 0 * * * /opt/custom/bin/zfs-snapshot-all automated_daily   >> /var/log/autosnap.log 2>&1
2 0 * * 0 /opt/custom/bin/zfs-snapshot-all automated_weekly  >> /var/log/autosnap.log 2>&1
3 0 1 * * /opt/custom/bin/zfs-snapshot-all automated_monthly >> /var/log/autosnap.log 2>&1
4 0 1 1 * /opt/custom/bin/zfs-snapshot-all automated_yearly  >> /var/log/autosnap.log 2>&1

And then zfs-prune-snapshots can be used to cleanup snapshots as they get too old... for example

11 0 * * * /opt/custom/bin/zfs-prune-snapshots -p automated_daily_   7d   >> /var/log/autosnap.log 2>&1
12 0 * * 0 /opt/custom/bin/zfs-prune-snapshots -p automated_weekly_  4w   >> /var/log/autosnap.log 2>&1
13 0 1 * * /opt/custom/bin/zfs-prune-snapshots -p automated_monthly_ 12M  >> /var/log/autosnap.log 2>&1
14 0 1 1 * /opt/custom/bin/zfs-prune-snapshots -p automated_yearly_  10y  >> /var/log/autosnap.log 2>&1

Usage

usage: zfs-snapshot-all [-hnx] <name> [[pool1] pool2 ...]

recursively snapshot all zpools

examples
    # zfs-snapshot-all foo
    snapshot all zpools with the prefix foo

    # zfs-snapshot-all bar pool1 pool2
    snapshot zpools pool1 and pool2 with the prefix bar

    # zfs-snapshot-all -x baz pool3
    snapshot zpool pool3 with the *exact* snapshot name 'baz'


options
    -h             print this message and exit
    -n             dry-run, don't actually create snapshots
    -x             don't automatically append the date in epoch to
                   the snapshot name
    -V             print the version number and exit

Development Notes

Style

shellcheck is used to check bash style. Use make check to run the style checker:

$ make check
awk 'length($0) > 80 { exit(1); }' zfs-snapshot-all
shellcheck zfs-snapshot-all

Bash style guide: https://www.daveeddy.com/bash/

Manpage

Use make man to regenerate the manpage:

$ make man
md2man-roff man/zfs-snapshot-all.md > man/zfs-snapshot-all.1
$ ./man/zfs-snapshot-all.1
<man page opens>

Manpages are generated with md2man which requires ruby-devel to be installed. Once ruby is installed, md2man can be installed locally with:

$ gem install --user-install md2man

License

MIT License

zfs-snapshot-all's People

Contributors

bahamas10 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.