Git Product home page Git Product logo

harvester-auto-backup's Introduction

Harvester Auto-Backup

Simple script to create backups of labeled VMs in Harvester, and provide smart aging of backups.

harvester-auto-backup scans your harvester cluster looking for for a specific label, and when it finds it on a VM creates a backup of that VM. It then checks the age of any existing backups and deletes them according to the retention policy.

Requirements

  • Harvester cluster with kubectl access
  • Configured backukp target in Harvester
  • Ability to edit the yaml of VMs in Harvester

Backup Target

A valid backup target must be configured in Harvester. This can be done by following the Harvester documentation.

Installation

Install the CronJob by applying the manifest from this repository:

kubectl apply -f https://raw.githubusercontent.com/jaevans/harvester-auto-backup/main/deploy.yaml

Or download and modify deploy.yaml to suit your needs.

Configuration

auto-backup takes the following arguments, specified in the CronJob resource, to configure its behavior:

Argument Description Required Default
--label The label to search for on VMs to backup yes
--verbose Enable verbose logging no false
--dry-run Enable dry-run mode (no backups will be created) no false
--namespace Only search this namespace for VMs to backup (not fully tested) no "" (All namespaces)

CronJob

The CronJob is configured to run every night at 02:00 UTC by default. You can modify this by editing the deploy.yaml file and changing the CronJob's spec.schedule field.

VM Label

The VM label is configured in the CronJob's spec.jobTemplate.spec.template.spec.containers[0].args[0] field. You can modify this by editing the deploy.yaml file and changing the field to any valid label you want to use to mark VMs for backup.

Retention Policy

A "smart" retention policy is applied to existing backups of the VMs. The retention policy is as follows:

  • Keep all backups for the past week
  • Keep one backup per week for the past 3 months
  • Keep one backup per month for the past year
  • Delete all backups more than a year old

These thresholds are currently hardcoded in the auto-backup script, and can be adjusted by modifying the retention variables keep_weekly_after, keep_monthly_after, and delete_after. All backups yunger than keep_weekly_after are kept, weekly backups younger than keep_monthly_after are kept, and then monthly backups are kept until delete_after.

License

This project is licensed under the Apache License 2.0 - see the LICENSE file for details.

harvester-auto-backup's People

Contributors

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