Posts Tagged ‘ linux

Backup your Virtualmin to S3

Hi!

Long time since my last post! I want to say happy new year to everyone who visits my blog and I hope all your wishes come true in this year. I have been very busy with my start-up company the lasts months (I even had to work in my 3 days annual vacation ;) ) so that’s why I didn’t upload any new article. So today I will show you a little script that will upload your Virtualmin backups to S3. I have a customer that have backups larger than 5Gb and I can’t upload them directly to S3 since the limit per file in S3 is 5 Gbs so I used the split command to have 1Gb pieces of the backup and then upload all to S3. To use this script you have to configure your Virtualmin to backup to a local folder (In this case /bkps) and then have a daily script that can be placed in /etc/cron.daily for example with the following content:

#!/bin/bash

# Clean backup folder for old files
echo “Cleaning old backups…”
/usr/bin/find /bkps -type f -mtime +5 -print
/usr/bin/find /bkps -type f -mtime +5 -exec rm -f {} \;

for bkpfile in `ls -1 /bkps/*.bkp`
do
echo “Generating MD5SUM for the original backup file $bkpfile…”
md5sum $bkpfile >> $bkpfile-md5sums
echo “Splitting backup file $bkpfile…”
split -a 1 -d -b 1073741824 –verbose $bkpfile $bkpfile-part
for splitbkpfile in `ls -1 $bkpfile-part*`
do
echo “Generating MD5SUM for split backup file $splitbkpfile…”
md5sum $splitbkpfile >> $bkpfile-md5sums
done
rm $bkpfile
done

# Upload backups to S3
su -l -s /bin/bash -c “s3cmd –delete-removed -v sync /bkps s3://YOURBUCKET”

As you can see above, my backups are created with the extension .bkp also I have used the s3cmd to have access to S3. The installation of s3cmd is very easy and it haves packages for almost all the Linux distributions.

I hope you enjoy this script and later I will share with you some of my experiences with AWS cloud services for a large project I worked the lasts months including Load Balancing, Auto Scaler, etc. I have created some nice scripts (I think) to make my life with the AWS, so stay tuned! (I promise that you will not have to wait 2 months to have news from me ;) )

Thank you very much for your time.

Cheers!

Update CentOS 5 PHP 5.1 to PHP 5.3

Hi,

In this little guide you will see how to update the CentOS 5 PHP 5 version (Which is 5.1.6) to the latest PHP version (Which now is 5.3) . I had to do this for a particular project that we have done in Elance.com which objective was to install a Linode server from scratch for LAMP services and a Control Panel (We installed Virtualmin which is great and is free). So let’s get some action:

# wget http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# wget http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
# rpm -Uvh remi-release-5*.rpm epel-release-5*.rpm

With the above command we have downloaded and installed the EPEL and REMI repositories, you might ask your self what does EPEL and REMI stand for? Let me clarify you that:

EPEL

Extra Packages for Enterprise Linux (EPEL) is a volunteer-based community effort from the Fedora project to create a repository of high-quality add-on packages for Red Hat Enterprise (RHEL) and its compatible spin-offs such as CentOS or Scientific Linux. Fedora is the upstream of RHEL and add-on packages for EPEL are sourced from the Fedora repository primarily and built against RHEL.

REMI

This is a repository created by Remi Collet with the aim to give support for old Fedora releases to allow them to install recent software, also it gives you the ability to have your CentOS/RHEL systems with the latest software available in the net.

Now it’s time to update our PHP to the latest one (Which is PHP 5.3.0 (cli) (built: Jul 19 2009 18:22:52) in this moment)

# yum --enablerepo=remi update php php-*

# /etc/init.d/httpd restart

And that’s it!

You can check your installed PHP version executing:

# php -v

That’s all folks! Happy updating! :)