reshifter: github.com/mhausenblas/reshifter/pkg/backup Index | Examples | Files

package backup

import "github.com/mhausenblas/reshifter/pkg/backup"

Package backup contains backup operations against etcd.

Index

Examples

Package Files

backup.go doc.go strategy.go

func Backup Uses

func Backup(endpoint, target, remote, bucket string) (string, error)

Backup iterates over well-known Kubernetes (distro) keys in an etcd server and creates a ZIP archive of the content in the target directory. On success, it returns the backup ID, which is the Unix time encoded point in time the backup operation was started, for example 1498050161. If remote and bucket is provided, the backup will be additional stored in this S3-compatible object store.

Shows how to back up a Kubernetes cluster by specifying the underlying etcd. It assumes that the etcd process is servering on 127.0.0.1:2379.

Code:

// define the URL etcd is available at:
etcdurl := "http://127.0.0.1:2379"

// using Minio play, a public S3-compatible sandbox
// for the remote storage available at https://play.minio.io:9000
// and the following credentials which need to be exposed
// as environment variables to the ReShifter process:
_ = os.Setenv("ACCESS_KEY_ID", "Q3AM3UQ867SPQQA43P2F")
_ = os.Setenv("SECRET_ACCESS_KEY", "zuf+tfteSlswRu7BJ86wekitnifILbZam1KYY3TG")

// carry out the backup of etcd underlying the Kubernetes cluster
// and handle errors as they occur:
backupid, err := Backup(etcdurl, "/tmp", "play.minio.io:9000", "2017-07-some-bucket")
if err != nil {
    log.Fatal(err)
    return
}
fmt.Printf("The backup completed successfully with ID %s\n", backupid)

Output:

The backup completed successfully with ID 1498847078

func List Uses

func List(remote, bucket string) ([]string, error)

List generates a list of available backup IDs. If remote and bucket is provided, the S3-compatible object store will be queried rather than the local work directory.

Package backup imports 17 packages (graph) and is imported by 2 packages. Updated 2017-10-30. Refresh now. Tools for package owners.