generate

package
v0.0.0-...-38ace23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 2, 2022 License: Apache-2.0 Imports: 16 Imported by: 0

README

Backup Repository - Backup & Restore commands generator

Purpose of this generator is to create procedures from templates for both Backup and Restore operations to use in automated way. Backup made using generated procedure should be possible to restore with a restore procedure in automated way.

The generator is having two output formats:

  • shell script
  • Kubernetes-like kind: Job and kind: Pod

Usage concept

  1. User prepares YAML file as input definition for both backup & restore
Params:
    hostname: postgres.db.svc.cluster.local
    port: 5432
    db: rkc-test
    user: riotkit
    password: "${DB_PASSWORD}" # injects a shell-syntax, put your password in a `kind: Secret` and mount as environment variable. You can also use $(cat /mnt/secret) syntax, be aware of newlines!

Repository:
    url: "https://example.org"
    token: "${BR_TOKEN}"
    encryptionKeyPath: "/var/lib/backup-repository/encryption.key"
    passphrase: "${GPG_PASSPHRASE}"
    recipient: "your-gpg@email.org"
    collectionId: "111-222-333-444"

  1. Next, User runs a generation command e.g. rkc backups generate backup --kubernetes --cron '*/30 * * *

In result the User gets prepared Kubernetes manifests that could be applied to the cluster.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBackupCommand

func NewBackupCommand() *cobra.Command

func NewBackupsGenerateCommand

func NewBackupsGenerateCommand() *cobra.Command

NewBackupsGenerateCommand creates the new command

func NewRestoreCommand

func NewRestoreCommand() *cobra.Command

Types

type SnippetGenerationCommand

type SnippetGenerationCommand struct {
	Template       string
	DefinitionFile string
	IsKubernetes   bool
	KeyPath        string
	OutputDir      string
	Schedule       string
	JobName        string
	Image          string
	Operation      string
	Namespace      string
}

func (*SnippetGenerationCommand) Run

type Templating

type Templating struct{}

func (*Templating) LoadVariables

func (t *Templating) LoadVariables(path string) (map[string]interface{}, error)

func (*Templating) RenderChart

func (t *Templating) RenderChart(script string, gpgKeyContent string, schedule string, jobName string, image string,
	valuesOverride map[interface{}]interface{}, namespace string) (string, error)

RenderChart Renders YAML files from 'chart/templates' directory combining Helm values from CLI switches and from .HelmValues

func (*Templating) RenderTemplate

func (t *Templating) RenderTemplate(name string, operation string, variables interface{}) (string, error)

RenderTemplate renders a Go-formatted template in order from (stops on first found):

  1. ~/.rkc/backups/templates/{backup,restore}/{Name}.tmpl

  2. ~/.rkc/backups/templates/base/{backup,restore}/{Name}.tmpl

    Templates in first directory are replaced only if the user has not modified them.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL