Skip to content

Instantly share code, notes, and snippets.

@jrmehle
jrmehle / db_backup.sh
Last active September 20, 2017 23:23 — forked from bendavis78/db_backup.sh
A simple database backup / rotation / prune script
#!/bin/bash
# for use with cron, eg:
# 0 3 * * * postgres /var/db/db_backup.sh foo_db
if [[ -z "$1" ]]; then
echo "Usage: $0 <db_name> [pg_dump args]"
exit 1
fi
module Paperclip
module Dimension
def get_size_of(name, thumbnail=nil)
return '0x0' unless get_path_of(name, thumbnail)
Geometry.from_file(get_path_of(name, thumbnail)).to_s
end
# calculates width using processor
def get_width_of(name, thumbnail=nil)
return 0 unless get_path_of(name, thumbnail)
# Run rake db:size to get a print of your database size in bytes.
# Run rake db:tables:size to get the sizes for individual tables
# Works for MySQL and PostgreSQL. Not tested elsewhere.
namespace :db do
desc 'Print data size for entire database'
task :size => :environment do
database_name = ActiveRecord::Base.connection.instance_variable_get("@config")[:database]
adapter = ActiveRecord::Base.connection.adapter_name.downcase
# How to setup multiple heroku accounts
# (assuming you already have one setup)
# make sure ~/bin is in your path
create ~/bin/hcred and populate it with the following:
1 #!/usr/bin/env ruby
2
3 `rm ~/.heroku/credentials`