项目作者: abednarik

项目描述 :
Script to backup a local dictory to an S3 backup.
高级语言: Python
项目地址: git://github.com/abednarik/backup2s3.git
创建时间: 2021-01-02T20:13:05Z
项目社区:https://github.com/abednarik/backup2s3

开源协议:

下载


Backup to S3

Script to backup a local directory to an S3 bucket.

DISCLAIMER This script was only tested in Ubuntu 18.04 with Python 3.6 and is not intended to be used in production.
Notifications emails are only sent to localhost.

Requirements

Install

  • Download backup2s3 script, save it in your PATH and give it execution permisssions.
  1. $ wget https://raw.githubusercontent.com/abednarik/backup2s3/master/backup2s3.py -O /usr/local/bin/backup2s3.py
  2. $ chmod +x /usr/local/bin/backup2s3.py
  • Install python modules with pip
  1. $ pip3 install boto3
  • Install AWS cli
  1. sudo apt-get install -y awscli
  • Configure AWS credentials
  1. $ aws configure
  2. AWS Access Key ID [None]: YOURKEYHERE
  3. AWS Secret Access Key [None]: YOURSECRETKEYHERE
  4. Default region name [None]: your-region

Configuration

  • Create a directory to store configurations files for this process. For example:
  1. $ sudo mkdir /etc/backup2s3
  • Create a configuration file with a descriptive name and place in the directory created above. For example apache2.cfg
  1. [backup2s3]
  2. local_path = /etc/apache2
  3. bucket = abednarik-backups
  4. retention = 7
  5. email = abednarik
Option Description
local_path path to directory to backup
bucket S3 bucket to store backupss
retention Numbers of days to keep backups
email Email address to send notifications after each run

Usage

Schedule a cron job to execute daily backups

Example

  • Edit crontab using
  1. sudo crontab -e
  • Add an entry for backup2s3 to run every day at midnight
  1. 0 0 * * * /usr/local/bin/backup2s3.py > /dev/null 2>&1

NOTE Make user user running this cron job is able to wirte to /var/log/backup2s3.log