Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bahamas10/zfs-snapshot-all
Recursively snapshot all zpools
https://github.com/bahamas10/zfs-snapshot-all
Last synced: about 2 months ago
JSON representation
Recursively snapshot all zpools
- Host: GitHub
- URL: https://github.com/bahamas10/zfs-snapshot-all
- Owner: bahamas10
- License: mit
- Created: 2015-11-23T05:43:33.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-11-12T18:46:05.000Z (about 6 years ago)
- Last Synced: 2024-08-14T10:16:10.922Z (4 months ago)
- Language: Shell
- Homepage: http://daveeddy.com/2015/12/05/automatic-zfs-snapshots-and-backups/
- Size: 6.84 KB
- Stars: 27
- Watchers: 4
- Forks: 15
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES.md
- License: LICENSE
Awesome Lists containing this project
README
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_1448256528Snapshot 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 takenSnapshot 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 $?
1This 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>&1And then [zfs-prune-snapshots](https://github.com/bahamas10/zfs-prune-snapshots)
can be used to cleanup snapshots as they get too old... for example11 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>&1Usage
-----usage: zfs-snapshot-all [-hnx] [[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 exitDevelopment Notes
-----------------### Style
[shellcheck](https://www.shellcheck.net/) 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-allBash 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
Manpages are generated with [md2man](https://github.com/sunaku/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