Coder Social home page Coder Social logo

s3cmd-backup's Introduction

Simple s3cmd backup script

This is a simple script that compresses a specified folder and loads it into an aws s3 bucket using s3cmd.

Getting Started

Prerequisites

  • Unix-like operating system
  • s3cmd is a command line tool that makes it possible to put/get files into/from a s3 bucket. Please make sure that s3cmd is installed and configured. Check the s3cmd installation guide here and run s3cmd --configure after installation.
  • zip or tar should be installed
  • A configured aws s3 bucket

Installation

via curl

$ curl -Lo backup https://git.io/fhMJy

via wget

$ wget -O backup https://git.io/fhMJy

via httpie

$ http -do backup https://git.io/fhMJy

via git clone

$ git clone https://github.com/MoonLiightz/s3cmd-backup.git
$ cd s3cmd-backup

Note

Don't forget to give the script execution permissions.

$ chmod +x backup

Configuration

To configure the script, edit the downloaded file with an editor of your choice like nano or something else. At the top of the file you will find some configuration options.

Config Option Description
BACKUP_PATH Path to the location without ending / of the folder which should be saved.
Example: If you want to save the folder myData located in /root than you should set BACKUP_PATH="/root"
BACKUP_FOLDER Name of the folder which should be saved.
Example: Based on the previous example you should set BACKUP_FOLDER="myData"
BACKUP_NAME Name of the backup file. The date on which the backup was created is automatically appended to the name.
Example: If you set BACKUP_NAME="myData-backup" the full name of the backup is myData-backup_year-month-day_hour-minute-second
S3_BUCKET_NAME Name of the s3 bucket where the backups will be stored.
Important: The name of the bucket and not the Bucket-ARN
Example: S3_BUCKET_NAME="mybucket"
S3_BUCKET_PATH Path in the s3 bucket without ending / where the backups will be stored.
Example: S3_BUCKET_PATH="/backups"
COMPRESSION The compression which will be used. Available are zip and tar
Example: For zip set COMPRESSION="zip" and for tar set COMPRESSION="tar"
TMP_PATH Path to a location where files can be temporarily stored. The path must exist.
Example: TMP_PATH="/tmp"

Usage

Basic

The script supports the following functionalities.

Create Backup

This command creates a backup and loads it into the specified s3 bucket.

$ ./backup create

List Backups

With this command you can list the backups stored in the s3 bucket.

$ ./backup list

Download Backup

To download a backup from the s3 bucket to the server you can use this command.

$ ./backup download <filename>

Cron

You can also execute the script with a cronjob. The following example creates a backup every night at 2 a.m.

0 2 * * * <path_to_script>/backup create

License

s3cmd-backup is released under the MIT license.

s3cmd-backup's People

Contributors

moonliightz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

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