Sohaib's Tech Blog

Something for every one

Amazon S3 Backup via S3tools — 2013

Amazon S3 Backup via S3tools

Amazon S3
Amazon S3

I wrote this HOW to on DirectAdmin Forum [adsenseyu2]

Guide is for CENTOS 6.x x32 or x64

yum install s3cmd -y – If you can’t install s3cmd then please follow the instructions

[adsenseyu2]

cd /etc/yum.repos.d
touch s3cmd.repo [adsenseyu2]
nano s3cmd.repo [adsenseyu2]
COPY THE CODE BELOW –

# Save this file to /etc/yum.repos.d on your system

# and run "yum install s3cmd"
# 
[s3tools]
name=Tools for managing Amazon S3 - Simple Storage Service (RHEL_6)
type=rpm-md
baseurl=http://s3tools.org/repo/RHEL_6/
gpgcheck=1
gpgkey=http://s3tools.org/repo/RHEL_6/repodata/repomd.xml.key
enabled=1

Try Above YUM Command again – This time it will install S3CMD, Once installation is completed try running the following command – It will configure your S3CMD using your AMAZON KEY AND Access ID.

Code:
s3cmd --configure

Once above is done – Create another file for example in /home/admin/user_backups or where ever you like

Code:
nano /home/admin/user_backups/backup.sh

COPY THE FOLLOWING CONTENT and SAVE
DONT FORGET TO chmod 777 backup.sh and then run it like ./backup.sh

So what this will upload all your content to AMAZON s3, but before you do this please create your bucket and folder inside your bucket for example , I have a BUCKET NAME – YOURBUCKETNAMEHERE inside that bucket I have a folder called Directadmin

#!/bin/bash
S3_BUCKET=YOURBUCKETNAMEHERE
DATE=`date +%d%m%Y_%H%M`
BACKUP_LOC=/home/admin/user_backups/
LOG=/tmp/log_$DATE
mysql_backup(){
echo "Syncing files from $BACKUP_LOC to s3 bucket" >> $LOG
    s3cmd sync -r $BACKUP_LOC s3://$S3_BUCKET/Directadmin/
}
mysql_backup
exit 0
Advertisements