Skip to content

Instantly share code, notes, and snippets.

View nagi's full-sized avatar

Andrew Nagi nagi

  • Magical Bytes Ltd
  • London, UK
View GitHub Profile
@nagi
nagi / mongo-backup.sh
Created December 13, 2016 16:16
Script to generate hourly, daily & monthly backups of a Mongo DB database
#!/bin/bash
MONGO_DATABASE="bingo"
MONGO_HOST="127.0.0.1"
MONGO_PORT="27017"
MONGODUMP_PATH="/usr/bin/mongodump"
BACKUPS_DIR="/home/some-user/database-backups/cronned"
BACKUP_NAME="latest"
# See http://m.onkey.org/running-rails-performance-tests-on-real-data
# fixed to work with Rails 3.2.15
# START : HAX HAX HAX
# Load Rails environment in 'test' mode
ENV["RAILS_ENV"] ||= "test"
require File.expand_path('../../config/environment', __FILE__)
# Re-establish db connection for 'performance' mode
ActiveRecord::Base.establish_connection(:performance)

#Recipe to Clean Up Ugly Ruby

Remove cruft matching regex

ack -l "######" | xargs ruby -i.bak -ne 'print if not /######/'
# check with git diff
find . | grep '\.bak$' | xargs rm