Backup shell script for my Rails applications
Howia lads,
Today I'd like to show you the optimal backup shell script for all of my Rails Applications.
Nobody love to setup the backup workflow, but all want to sleep well and have their data duplicated somewhere like Amazon S3 :)
Here the script who take care of yours backup process
# Take care about folders structure for the usual script workflow: # /home/demo/backup/ # /home/demo/backup/redmine_folder/ # /home/demo/backup/redmine_folder/script.sh - the following script should be landing here # /home/demo/backup/redmine_folder/files # /home/demo/public_html/ # /home/demo/public_html/redmine_folder # # crontab -e -u demo # 0 20 * * * /home/demo/backup/redmine_folder/script.sh # ---BACKUP SCRIPT--- #!/bin/sh folder=redmine_folder db=redmine_production # Change directory and remove files older than 30days cd ~/backup/$folder/files find . -mtime +30 |xargs rm # Database file01=$folder.db_$(date +"%Y_%m_%d_%H-%M") mysqldump -u user_name -pmy_sycret_password --single-transaction $db | gzip -c > $file01.gz # App file02=$folder.app_$(date +"%Y_%m_%d_%H-%M") tar czf ~/backup/$folder/files/$file02.tgz ~/public_html/$folder > /dev/null # S3 sync ruby ~/backup/s3sync/s3cmd.rb put s3bucket:backup/$folder/db/$file01.gz $file01.gz ruby ~/backup/s3sync/s3cmd.rb put s3bucket:backup/$folder/app/$file02.tgz $file02.tgz # ---BACKUP SCRIPT---
jQuery beatiful code examples
I really like the semantics of jQuery, is fairly short and predictable.
Look at the code, it is not overloaded with ambiguous and unclear structures.
Like Ruby, the methods often returns a jQuery object, so you can create a chain of methods.
I want to share the code that I wrote last night. If you are not familiar jQuery, so look over the code.
...
$("#pics_hide").click(function(){
$("#images div:first-child").animate({opacity: "0.1"}, 300,
function(){$(this).next().animate({opacity: "0.1"},
arguments.callee);
return false
}
);
});
$("#pics_show").click(function(){
$("#images div:last-child").animate({opacity: "1.0"}, 300,
function(){$(this).prev().animate({opacity:"1.0"},
arguments.callee);
return false
}
);
});
$("#pics_move").hover(
function(){
$("#images div:even").hide("slow")
},
function(){
$("#images div:even").show("slow")
});
$("#pics_reorder").click(function(){
$("#images div:last-child")
.insertBefore($("#images div:first-child"));
$("#images div:even").animate({opacity: "0.4"}, 300);
$("#images div:odd").animate({opacity: "1.0"}, 300);
});
$("#pics_anim").click(function(){
$("#images div:odd").animate({top: '-=20px'}, 300);
$("#images div:even").animate({top: '+=20px'}, 300);
});
...
Internet Explorer Free under Ubuntu Linux with VirtualBox
My job is web application development, so I have to test my projects under most popular browsers, like Firefox, Internet Explorer, Opera and Google Chrome.
Firefox, Opera, GoogleChrome work great under my Ubuntu Box, and the other once work under Wine.
*Internet Explorer*. It's pain to setup IE6 and IE7, because you can take a look of many bugs with render html and vml.
Just forget Wine for the purpose!
Microsoft give us FREE virtual PC images with IE6, IE7, IE8 aboard!
Don't you believe?
Internet Explorer Application Compatibility VPC Image
Brief Description
VPC Hard Disk Image for testing websites with different IE versions on Windows XP SP2, Windows XP SP3 and Windows Vista
| IE6-XPSP3.exe | 407.3 MB |
| IE7-VIS1.exe | 700.0 MB |
| IE7-VIS2.rar | 700.0 MB |
| IE7-VIS3.rar | 590.5 MB |
| IE7-XPSP3.exe | 512.0 MB |
| IE8RC1-XPSP3.exe | 495.8 MB |
Licence: Free.
After you have file downloaded, just unrar it and add select VHD file extracted earliert to VirtualBox. link
This link might be helpful to install last VirtualBox for VHD image file using.
Download
Amazon AWS EC2 RubyOnRails Rails-All-in-one
As you may know, standard template “Amazon EC2 Rails-All-in-one-trial” by Amazon AWS is not good… yeap, it is. Let me show you how fix it by your hads :)
Let’s start. We have a useful EC2 based on CentOS 5.2. Great enterprise linux for the Rails application. But Ruby 1.8.5 on aboard, it’s deeply out-of-date…
http://rubyonrails.org/download We recommend Ruby 1.8.7 for use with Rails. Ruby 1.8.6, 1.8.5, 1.8.4 and 1.8.2 are still usable too, but version 1.8.3 is not.
Well, do you want to run Rails with old Ruby? If, you have 2 ways to get newer Ruby version:
- Ruby Enterprise edition as additional package, who need to install from sources (http://www.rubyenterpriseedition.com/download.html). Telling the truth, feel free to install it, very easy.
- Use extra repo to the CentOS who include good version of Ruby 1.8.6 (patch 111) and other dependent libraries
http://www.centos.org/modules/newbb/viewtopic.php?topic_id=1182
or followed bash scrip
#!/bin/bash -e cat<<EOF> /etc/yum.repos.d/ruby.repo [ruby] name=ruby baseurl=http://repo.premiumhelp.eu/ruby/ gpgcheck=0 enabled=0 EOF yum update -y yum --enablerepo=ruby install ruby -y yum --enablerepo=ruby install ruby-mysql -y
Apache2 httpd improving performance mod_deflate gzip
How often do you think about improving performance of Apache2 httpd web-server?
“It’s too slow”, “we need more powerfull server”, etc.
Telling the truth, default settings of Apache2 aren’t good and it’s best to try optimizing those first, before thinking of more advanced solutions.
Mod_deflate in apache2 is pretty much the same as mod_gzip in apache1.3, and mod_deflate is included with the apache2 source package. Both modules allow compressing of the apache server on the fly
So, I know, professinals from Amazon EC2 AMI have optimized apache configuration file. Let me show that to site.vhost
<VirtualHost *:80>
...
# Deflate
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/xml application/xhtml+xml text/javascript text/css application/x-javascript
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE !no-gzip !gzip-only-text/html
DeflateCompressionLevel 9
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0
...
</VirtualHost>
It’s simillar to nginx settings gzip_comp_level.
So, I have Apache2 httpd with great perfomance improvement with DeflateCompressionLevel.
RailsRumble
I was very happy to participate in RailsRumble last weekend.
We developed Rdocker project, which makes rdoc browsing of favorite ruby projects less painful.
Rdocker - Personalized RDoc browser and Gem server

Please check this out http://vote.railsrumble.com/entries?page=4