Amazon S3 Backup Script 1

# Shell script to handle onsite drupal mysql backups, and cron

#Variables

CLIENT_URL=http://client.org
CLIENT_DOMAIN=client.org
CLIENT_MYSQL_USERNAME=client
CLIENT_MYSQL_PASSWORD=password
DRUPAL_DB_NAME=client_drupal
DRUPAL_PATH=/path/to/vhost
S3_BUCKET_NAME=bucket-name
S3_ACCESS_KEY=ACCESS_KEY
S3_SECRET_KEY=SECRET KEY

### Site cron ###
wget -O - -q -t 1 ${CLIENT_URL}/cron.php

### Zip up the files ###
tar -czf ${DRUPAL_PATH}/mysql/${CLIENT_DOMAIN}.tar.gz ${DRUPAL_PATH}/htdocs/ > /dev/null 2>&1

### Site Drupal backup ###
mysqldump -u ${CLIENT_MYSQL_USERNAME} -p${CLIENT_MYSQL_PASSWORD} ${DRUPAL_DB_NAME} > ${DRUPAL_PATH}/mysql/${DRUPAL_DB_NAME}.sql

### S3 File Backup ###

# Mount the s3 file system
/usr/bin/s3fs ${S3_BUCKET_NAME} -o accessKeyId=${S3_ACCESS_KEY} -o secretAccessKey=${S3_SECRET_KEY} /mnt/s3

#Copy the files
cp ${DRUPAL_PATH}/mysql/${CLIENT_DOMAIN}.tar.gz /mnt/s3/

#Copy the database
cp ${DRUPAL_PATH}/mysql/${DRUPAL_DB_NAME}.sql /mnt/s3/

#Unmount s3fs
/bin/umount /mnt/s3

{ 1 trackback }

Amazon S3 for web server backup
06.30.10 at 8:25 am

{ 0 comments… add one now }

Leave a Comment

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>