Skip to content

Instantly share code, notes, and snippets.

View rantoniuk's full-sized avatar
Enjoying espresso

Radek Antoniuk rantoniuk

Enjoying espresso
View GitHub Profile
@rantoniuk
rantoniuk / check_jmx_params.pl
Created September 27, 2011 22:32
check_jmx_params - Nagios script for monitoring Tomcat PermGen OldGen and currentThreads through JNDI JMX
#!/usr/bin/perl
use strict;
use warnings;
use POSIX;
use Getopt::Std;
getopt('h');
##################################################################
# Monitoring JMX by Radek Antoniuk <[email protected]> #
##################################################################
@rantoniuk
rantoniuk / BackupMigrate
Created February 2, 2011 17:45
Backup before migration and migrate task.
namespace :project do desc "Backup before migration and migrate"
task :update => [:environment] do
Rake::Task["db:backup"].invoke
Rake::Task["db:migrate"].invoke
end
end
@rantoniuk
rantoniuk / backup.rake
Created January 10, 2011 12:53
Rake task for backing up MySQL database in Rails projects
namespace :db do desc "Backup project database. Options: DIR=backups RAILS_ENV=production MAX=7"
task :backup => [:environment] do
datestamp = Time.now.strftime("%Y-%m-%d_%H-%M-%S")
base_path = Rails.root
base_path = File.join(base_path, ENV["DIR"] || "backups")
backup_base = File.join(base_path, 'db_backups')
backup_folder = File.join(backup_base, datestamp)
backup_file = File.join(backup_folder, "#{RAILS_ENV}_dump.sql")
FileUtils.mkdir_p(backup_folder)
db_config = ActiveRecord::Base.configurations[RAILS_ENV]