Skip to content

Latest commit

 

History

History
49 lines (36 loc) · 1.21 KB

README.md

File metadata and controls

49 lines (36 loc) · 1.21 KB

sftp-s3-backup

A simple utility to backup the files on sftp to s3

Usage:

It exposes a simple utility to backup the files onto S3 from the sftp. The usage pattern is as follows:

package main

import (
  "log",
  backup "github.com/babbarshaer/sftp-s3-backup"
)

func main() {

  config := backup.Config{
    User:              "user",
    Address:           "address",
    Port:              22,
    PublicKeyLocation: "/home/user/.ssh/id_rsa.pub",
  }

  client := backup.Client(config)
  err := client.Init()
  if err != nil {
    log.Fatalf("Unable to initialize the client: %s", err.Error())
  }

  defer client.Close()

  err = client.Backup(
    "/data/user/uploads",
    "aws.bucket",
    backup.DefaultPathTransformer)

  // If we don't want the default path transformer
  // we can override it with our own implementation.

  if err != nil {
    log.Fatalf("Unable to backup, err: %s", err.Error())
  }
}

AWS Variables

In order to backup the files onto S3, we need to access the AWS variables which would allow us to login to the platform and upload the information into corresponding bucket. More information could be read at AWS Env