Backup a folder to AWS S3, once or periodically

Overview

awsbck

This utility lets you compress a folder and upload it to a AWS S3 bucket, once or periodically.


Disclaimer

This software is in a beta stage and, although it has not caused any problems in testing, I wouldn't recommend it for production use.

Use at your own risks!

The CLI will certainly change, but any breaking change should mean an increase in the minor version number as per semver , until it reaches 1.0.0. New features that are backwards-compatible and bug fixes will lead to patch number bumps until then.

Usage

Usage: awsbck [OPTIONS] --bucket <BUCKET> --id <KEY_ID> --key <KEY> <FOLDER>

Arguments:
  <FOLDER>  Path to the folder to backup [env: AWSBCK_FOLDER=]

Options:
  -i, --interval <SECONDS>  Specify an interval in seconds to run the backup periodically [env: AWSBCK_INTERVAL=]
  -f, --filename <NAME>     The name of the archive that will be uploaded to S3, without extension (optional) [env: AWSBCK_FILENAME=]
  -r, --region <REGION>     The AWS S3 region [env: AWS_REGION=] [default: us-east-1]
  -b, --bucket <BUCKET>     The AWS S3 bucket name [env: AWS_BUCKET=]
      --id <KEY_ID>         The AWS S3 access key ID [env: AWS_ACCESS_KEY_ID=]
  -k, --key <KEY>           The AWS S3 secret access key [env: AWS_SECRET_ACCESS_KEY=]
  -h, --help                Print help (see more with '--help')
  -V, --version             Print version

CLI arguments take precedence over environment variables.

The --filename option accepts ASCII alphanumeric characters and !-_.*'()/. Other characters will be discarded.

Example

# The .env file in the current directory is read by awsbck
$ cat .env
AWS_REGION="eu-central-1"
AWS_ACCESS_KEY_ID="YOUR_KEY_ID"
AWS_SECRET_ACCESS_KEY="yoursecret"

$ awsbck -i 3600 -b my_bucket /my_folder

Docker example

$ export AWS_REGION="eu-central-1"
$ export AWS_ACCESS_KEY_ID="YOUR_KEY_ID"
$ export AWS_SECRET_ACCESS_KEY="yoursecret"
$ docker run \
  --rm \
  --mount type=bind,src="$(pwd)"/target,dst=/target,readonly \
  -e AWS_REGION -e AWS_ACCESS_KEY_ID -e AWS_SECRET_ACCESS_KEY \
  vbersier/awsbck:latest \
  -i 3600 -b my_bucket /target

Installation

Prebuilt binaries

Check out the releases for prebuilt binaries.

Cargo

$ cargo install awsbck

Docker

This utility is available as a docker image vbersier/awsbck.

There are two tag variants, one running as a non-root user (latest) and one as a root user (root-latest).

This image is particularly useful to backup named volumes in docker. If you encounter problems where the awsbck logs report a permissions problem, then you can try to switch to the root-latest tag.

Below an example of using it with docker compose. In order to make sure the backup happens properly, we can't just copy the db data, as it might be in the middle of a write or other operation. Thus we send the pg_dumpall command and store the resulting dump to a separate volume that we can backup to S3.

---
version: '3.2'

volumes:
  # the first volume is to persist the database raw data
  database:
  # this volume will be used to share the dump file with awsbck
  database-backup:

services:
  postgresql:
    image: postgres:14
    restart: unless-stopped
    volumes:
      - type: volume
        source: database
        target: /var/lib/postgresql/data/
      - type: volume
        source: database-backup
        target: /backup
  # this service will send a dump command to the postgres container periodically (here 6h)
  # and store the resulting file in the `database-backup` volume mounted at `/backup`
  postgres-backup:
    image: docker:cli
    container_name: postgres_backup
    volumes:
      - type: bind
        source: /var/run/docker.sock
        target: /var/run/docker.sock
    command:
      [
        '/bin/sh',
        '-c',
        'while true; do sleep 21600; docker exec -t postgres pg_dumpall -c -U postgres > /backup/dump_database.sql; done'
      ]
  # we mount the backup volume as read-only and back up the SQL dump every 24h
  awsbck:
    image: vbersier/awsbck:latest
    restart: unless-stopped
    volumes:
      - type: volume
        source: database-backup
        target: /database
        read_only: true
    environment:
      AWSBCK_FOLDER: /database
      AWSBCK_INTERVAL: 86400
      AWS_REGION: eu-central-1
      AWS_BUCKET: my_bucket
      AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID
      AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY
You might also like...
Postgres proxy which allows tools that don't natively supports IAM auth to connect to AWS RDS instances.

rds-iamauth-proxy rds-proxy lets you make use of IAM-based authentication to AWS RDS instances from tools that don't natively support that method of a

A tool to run web applications on AWS Lambda without changing code.
A tool to run web applications on AWS Lambda without changing code.

AWS Lambda Adapter A tool to run web applications on AWS Lambda without changing code. How does it work? AWS Lambda Adapter supports AWS Lambda functi

Cookiecutter templates for Serverless applications using AWS SAM and the Rust programming language.

Cookiecutter SAM template for Lambda functions in Rust This is a Cookiecutter template to create a serverless application based on the Serverless Appl

πŸ“¦ πŸš€ a smooth-talking smuggler of Rust HTTP functions into AWS lambda
πŸ“¦ πŸš€ a smooth-talking smuggler of Rust HTTP functions into AWS lambda

lando 🚧 maintenance mode ahead 🚧 As of this announcement AWS not officialy supports Rust through this project. As mentioned below this projects goal

Ref Arch: Serverless GraphQL in Rust on AWS
Ref Arch: Serverless GraphQL in Rust on AWS

A Whole Hog Reference Architecture for an Apollo Federation-Ready, Serverless, Rust-Based GraphQL Microservice on AWS using Cloud Development Kit (CDK)

cargo-lambda a Cargo subcommand to help you work with AWS Lambda

cargo-lambda cargo-lambda is a Cargo subcommand to help you work with AWS Lambda. This subcommand compiles AWS Lambda functions natively and produces

cargo-lambda is a Cargo subcommand to help you work with AWS Lambda.

cargo-lambda cargo-lambda is a Cargo subcommand to help you work with AWS Lambda. The new subcommand creates a basic Rust package from a well defined

A Rust runtime for AWS Lambda

Rust Runtime for AWS Lambda This package makes it easy to run AWS Lambda Functions written in Rust. This workspace includes multiple crates: lambda-ru

Managing schema for AWS Athena in GitOps-style

athena-rs Managing AWS Athena Schemas Installation $ cargo install --git https://github.com/duyet/athena-rs $ athena --help athena 0.1.0 Duyet me@du

Comments
  • tests: add end-to-end testing

    tests: add end-to-end testing

    Potentially using https://hub.docker.com/r/adobe/s3mock/

    let shared_config = aws_config::from_env()
            .region(params.aws_region.region().await)
            .endpoint_url(endpoint_url) // use the local URL if testing
            .load()
            .await;
    

    More reading material:

    https://docs.rs/dockertest/latest/dockertest/

    https://docs.rs/testcontainers/latest/testcontainers/

    opened by beeb 0
  • Refactor the archive file interface and visibility of public members

    Refactor the archive file interface and visibility of public members

    This new struct allows to keep a reference to the tempdir so that it doesn't get dropped prematurely (and thus deleted). Changed the visibility of all pub members to pub(crate).

    opened by beeb 0
  • feat: sanitize the desired filename

    feat: sanitize the desired filename

    Follow the recommended guidelines at https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-keys.html

    The following special chars (besides ASCII alphanumeric) are retained:

    • Exclamation point (!)
    • Hyphen (-)
    • Underscore (_)
    • Period (.)
    • Asterisk (*)
    • Single quote (')
    • Open parenthesis (()
    • Close parenthesis ())
    opened by beeb 0
Releases(v0.2.11)
Rs.aws-login - A command line utility to simplify logging into AWS services.

aws-login A command line utility to simplify logging into AWS accounts and services. $ aws-login use ? Please select a profile to use: β€Ί ❯ dev-read

Kevin Herrera 11 Oct 30, 2022
Creates a DLL that runs a payload once injected into a process.

Educational purposes only Don't use this project maliciously. Prerequisites Install rust Install windows toolchain Setup Run cargo run --bin builder -

RadonCoding 3 Aug 27, 2022
Incremental, multi-version remote backup tool for block devices.

bsync Incremental, multi-version remote backup tool for block devices. The on-disk backup format is a SQLite database and I've been dogfooding this on

Heyang Zhou 7 Aug 21, 2022
This plugin provides an interface for storing unencrypted values on the application cache folder.

Tauri Plugin Store This plugin provides an interface for storing unencrypted values on the application cache folder. Architecture This repo shape migh

Tauri 128 Jan 1, 2023
A tool for investigating file system and folder contents and their changes.

Sniff A tool for investigating file systems and folder contents and their changes. Sniff can create snapshots of file systems and folders, storing has

Niclas Schwarzlose 6 Jan 14, 2023
Remote Secret Editor for AWS Secret Manager

Barberousse - Remote Secrets Editor About Usage Options Printing Editing Copying RoadMap 1.0 1.1 Future About A project aimed to avoid downloading sec

Mohamed Zenadi 18 Sep 28, 2021
Rust client for AWS Infinidash service.

AWS Infinidash - Fully featured Rust client Fully featured AWS Infinidash client for Rust applications. You can use the AWS Infinidash client to make

Rafael CarΓ­cio 15 Feb 12, 2022
Rusoto is an AWS SDK for Rust

Rusoto is an AWS SDK for Rust You may be looking for: An overview of Rusoto AWS services supported by Rusoto API documentation Getting help with Rusot

null 2.6k Jan 3, 2023
Easy switch between AWS Profiles and Regions

AWSP - CLI To Manage your AWS Profiles! AWSP provides an interactive terminal to interact with your AWS Profiles. The aim of this project is to make i

KubeOps Skills 14 Dec 25, 2022
Simple fake AWS Cognito User Pool API server for development.

Fakey Cognito ?? Homepage Simple fake AWS Cognito API server for development. βœ… Implemented features AdminXxx on User Pools API. Get Started # run wit

naokirin 4 Aug 30, 2022