marius / zsnap Goto Github PK
View Code? Open in Web Editor NEWA ruby script to automatically create and delete zfs snapshots from cron
A ruby script to automatically create and delete zfs snapshots from cron
Sometimes I like to make snapshot for overlapped zfs with different rules.
For example,
tank/home:
recursive: true
creation_rule:
at_multiple: 10
preservation_rules:
- { for_minutes: 30, at_multiple: 0, offset: 0 }
tank/home/important_user:
creation_rule:
at_multiple: 10
preservation_rules:
- { for_minutes: 90, at_multiple: 0, offset: 0 }
- { for_minutes: 1440, at_multiple: 60, offset: 0 }
- { for_minutes: 10080, at_multiple: 720, offset: 0 }
That is, use general rules recursively and specific rules for individual subtree.
However, zfs-snapshot-mgmt may expire old snapshots using rules from upper level.
Hi,
It would be quite useful to be able to specify dataset names with -d to (with -r, recursively, or without, non-recursively) expire snapshots under just those areas. This would make things easier when sending snapshots to a central system for backups, and having different retention policies for different datasets (which may also differ from the retention policies on the systems that made them).
Thanks,
John
If one has 'root' mounted on a pool directly, as follows:
# df -h
Filesystem Size Used Avail Capacity Mounted on
tank 1.9T 116M 1.9T 0% /
then the zfs-snapshot-mgmt script fails on line 157:
name[/\A.*?\//].chop
There is nothing to chop. I fixed this the hard way, since I don't now ruby at all:
# diff zfs-snapshot-mgmt zfs-snapshot-mgmt.orig
|57,162c157
< if name[/\A.*?\//]
< name[/\A.*?\//].chop
< else
< #special case when FS is directly mounted on the pool itself (usually mounted on "/" (legacy))
< name
< end
---
> name[/\A.*?\//].chop
/usr/local/bin/zfs-snapshot-mgmt:132:in
join': can't convert nil into String (TypeError) from /usr/local/bin/zfs-snapshot-mgmt:132:in
snapshots'
from /usr/local/bin/zfs-snapshot-mgmt:139:insnapshots_to_remove' from /usr/local/bin/zfs-snapshot-mgmt:147:in
remove_snapshots'
from /usr/local/bin/zfs-snapshot-mgmt:215 from
/usr/local/bin/zfs-snapshot-mgmt:212:in `each' from
/usr/local/bin/zfs-snapshot-mgmt:212
Every line -= 2.
@mount_point is nil when FS not mounted. Maybe change function to use zfs list -t snapshot.
If ZFS is resilvering, creating a snapshot restarts the resilvering...
see scrubbing!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.