Coder Social home page Coder Social logo

s3-shell-backups's Introduction

Amazon S3 Backup Scripts

This is a collection of Amazon S3 backup scripts for unix-based systems. The scripts make use of s3cmd (website) to backup files and databases to S3.

The s3-mysql-backup.sh script performs the following operations each time you run it:

  1. Checks, repairs, and optimizes each MySQL database.
  2. Dumps each database into its own .sql file.
  3. Tars all of the .sql files into a directory on the server.
  4. Uploads the tarred file to S3 and deletes the tarred file from the local server.
  5. Deletes backups older than 7 days from the S3 bucket.

Setup

  1. Install s3cmd. See s3tools.org/repositories for instructions.
  2. Configure s3cmd to work with your AWS account: s3cmd --configure. You can access or generate your AWS security credentials here.
  3. Create an S3 bucket: s3cmd mb s3://my-database-backups.
  4. Put the *.sh backup script somewhere on your server (ie - /root/scripts).
  5. Give the *.sh backup script 755 permissions: chmod 755 /root/scripts/backups/s3-mysql-backup.sh.
  6. Edit the variables near the top of backup script to match your bucket, directory, and MySQL authentication.

Example Cron Usage

  1. Edit your crontab: crontab -e.

  2. Add the following line to your crontab. This will execute the backup script at 2am every day and will email you the results of the run.

     0 2 * * * /path/to/your/script.sh |mail -s "Backup Cron Output" -c [email protected]
    

s3-shell-backups's People

Contributors

joshkraemer avatar priidikvaikla avatar

Watchers

James Cloos 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.