Coder Social home page Coder Social logo

stuvusit / zfs-snap-manager-role Goto Github PK

View Code? Open in Web Editor NEW
2.0 4.0 0.0 41 KB

Ansible role to install and configure zfs-snap-manager

License: Creative Commons Attribution Share Alike 4.0 International

Jinja 100.00%
ansible stuvus ubuntu role zfs-snap-manager zfs storage snapshot python

zfs-snap-manager-role's Introduction

zfs-snap-manager

This role installs and configures zfs-snap-manager, a tool to automatically create, replicate and destroy ZFS snapshots.

Requirements

An apt-based distribution (target and controller as well). On the controlling machine, git has to be installed. Obviously, any ZFS filesystems that should be snapshotted must exist.

Role Variables

Name Mandatory / Default Description
global_cache_dir $ansible_env.HOME/.cache cache directory to clone git repo to
zfs_snap_manager_version 0.2.0 zfs-snap-manager version to use
zfs_parent_fs Parent pool or filesystem (optionally prepended to all datasets)
zfs_filesystems [] List of filesystems to be snapshotted. Snapshots can be configured using the dict item snapshots. For its content see [snapshot configuration](#snapshot configuration)
zvols [] List of zvols to be snapshotted. Snapshots can be configured using the dict item snapshots. For its content see [snapshot configuration](#snapshot configuration)

Defaults for the snapshot dict can be set by prepending zfs_snapshot_default_, e.g. zfs_snapshot_default_replicate_endpoint.

Snapshot configuration

Name Default Description
mountpoint (omitted) Points to the location to which the dataset is mounted. Only needed when time = trigger
time 04:00 Can be either a timestamp in 24h notation after which a snapshot needs to be taken. It can also be trigger indicating that it will take a snapshot as soon as a file with name .trigger is found in the dataset's mountpoint. This can be used in case data is for example rsynced to the dataset.
snapshot True (boolean) Indicates whether a snapshot should be taken or not. It might be possible that only cleaning needs to be executed if this dataset is actually a replication target for another machine.
replicate_endpoint (omitted) Can be left empty if replicating on localhost (e.g. copying snapshots to other pool). Should be omitted if no replication is required.
replicate_target (omitted) The target to which the snapshots should be send. Should be omitted if no replication is required or a replication_source is specified.
replicate_source (omitted) The source from which to pull the snapshots to receive onto the local dataset. Should be omitted if no replication is required or a replication_target is specified.
compression (omitted) Indicates the compression program to pipe remote replicated snapshots through (for use in low-bandwidth setups.) The compression utility should accept standard compression flags (-c for standard output, -d for decompress.)
schema 7d3w11m4y In case the snapshots should be cleaned, this is the schema the manager will use to clean.
preexec (omitted) A command that will be executed, before snapshot/replication. Should be omitted if nothing should be executed
postexec (omitted) A command that will be executed, after snapshot/replication, but before the cleanup. Should be omitted if nothing should be executed

Note that recursive snapshotting is not supported by zfs-snap-manager. For more information on configuration and constraints thereof, consider reading the documentation at zfs-snap-manager.

Example Playbook

zfs_parent_fs: rpool
zfs_filesystems:
  - name: test
  - name: zroot
    snapshots:
      time: "14:00"
      schema: 10d5w1m10y
      replicate_endpoint: "ssh -p 2345 my.remote.server.org"
      replicate_target: tank/backups/rootfs
      compression: gzip
  - name: data
    snapshots:
      mountpoint: /mnt/data
      time: trigger
      snapshot: True
      schema: 5d0w0m0y
      preexec: "echo \"starting\" | mail [email protected]"
      postexec: "echo \"finished\" | mail [email protected]"
  - name: zvol
    snapshots:
      time: "22:00"
  - name: backups/data
    snapshots:
      mountpoint: "/mnt/backups/data"
      snapshot: False
      replicate_endpoint: "ssh other.remote.server.org"
      replicate_source: zpool/data

Results

rpool/test will be snapshotted locally daily at 04:00 and snapshots will be cleaned up with the default schema 7d3w11m4y.

rpool/zroot will be snapshotted at 14:00 with schema 10d5w1m10y and replicated to an example host (to destination dataset tank/backups/rootfs using gzip as compression).

rpool/data will be snapshotted by placing a .trigger file in /mnt/data. Only snapshots created in the last 5 days are kept. Before and after snapshotting, an email will be sent.

rpool/zvol is being snapshotted with the default schema 7d3w11m4y every day at 22:00.

rpool/backups/data will not be snapshotted but pulls snapshots from zpool/data residing at remote host other.remote.server.org to the local dataset of this name.

License

This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Author Information

zfs-snap-manager-role's People

Contributors

dasj avatar haslersn avatar mr-pi avatar neumantm avatar slothofanarchy avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

zfs-snap-manager-role's Issues

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.