Tool to do backup of the selected directories and files on a server and send the resulting TAR file to AWS S3.
-
An IAM User or an AWS IAM Role attached to the EC2 instance (only for executions from EC2 instances) with the following IAM policy attached:
Policy Name : AmazonS3FullAccess { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "s3:*", "Resource": "*" } ] }
-
Pip tool for Python packages management. Installation:
$ curl -O https://bootstrap.pypa.io/get-pip.py $ sudo python get-pip.py
-
AWS CLI to configure the profile to use (access key and/or region). Installation and configuration:
$ sudo pip install awscli $ aws configure [--profile <profile-name>] AWS Access Key ID [None]: <access_key_id> # Leave blank in EC2 instances with associated IAM Role AWS Secret Access Key [None]: <secret_access_key> # Leave blank in EC2 instances with associated IAM Role Default region name [None]: <region> # eu-west-1, eu-central-1, us-east-1, ... Default output format [None]:
-
Clone the project in the path you want:
$ git clone https://github.com/rubenmromero/files-s3-backup.git
-
Create a copy of
fs3backup.conf.dist
template asconf/fs3backup.conf
and set the backup properties with the appropriate values:# From the project root folder $ cp conf/fs3backup.conf.dist conf/fs3backup.conf $ vi conf/fs3backup.conf
-
If you want to schedule the periodic tool execution, copy the
files-s3-backup
template to the/etc/cron.d
directory and replace the existing<tags>
by the appropriate values:# From the project root folder $ sudo cp cron.d/files-s3-backup /etc/cron.d $ sudo vi cron.d/files-s3-backup
Once set up the backup properties in the conf/fs3backup.conf
file, simply run bin/fs3backup.sh
script as follows:
# ./bin/fs3backup.sh