Script to backup a local dictory to an S3 backup.
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.
$ wget https://raw.githubusercontent.com/abednarik/backup2s3/master/backup2s3.py -O /usr/local/bin/backup2s3.py
$ chmod +x /usr/local/bin/backup2s3.py
$ pip3 install boto3
sudo apt-get install -y awscli
$ aws configure
AWS Access Key ID [None]: YOURKEYHERE
AWS Secret Access Key [None]: YOURSECRETKEYHERE
Default region name [None]: your-region
$ sudo mkdir /etc/backup2s3
apache2.cfg
[backup2s3]
local_path = /etc/apache2
bucket = abednarik-backups
retention = 7
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 address to send notifications after each run |
Schedule a cron job to execute daily backups
sudo crontab -e
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