Skip to content

Instantly share code, notes, and snippets.

@jschoolcraft
Created February 4, 2011 12:23
Show Gist options
  • Select an option

  • Save jschoolcraft/811054 to your computer and use it in GitHub Desktop.

Select an option

Save jschoolcraft/811054 to your computer and use it in GitHub Desktop.
my astrails-safe backup (part of it anyway)
mysqldump do
options "-ceKq --single-transaction --create-options"
username = "root"
pass = "redacted"
user username
password pass
socket "/var/run/mysqld/mysqld.sock"
dbs = IO.popen("/usr/bin/mysql -u #{username} -p#{pass} -e 'show databases' --batch --skip-column-names")
databases = dbs.readlines
dbs.close
databases.each do |db|
database db.chomp.to_sym
end
end
tar do
options "-h" # dereference symlinks
archive "dot-configs", :files => "/home/*/.[^.]*"
["/var/www/wp-sites", "/var/www/apps"].each do |directory|
Dir.foreach(directory) do |sub_dir|
target = "#{directory}/#{sub_dir}"
if sub_dir.length > 2 # ignoring . and ..
archive sub_dir, :files => "#{target}/current/", :exclude => ["#{target}/current/logs", "#{target}/current/tmp"]
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment