Skip to content

Instantly share code, notes, and snippets.

@jtadeulopes
Created December 24, 2010 03:44
Show Gist options
  • Save jtadeulopes/753877 to your computer and use it in GitHub Desktop.
Save jtadeulopes/753877 to your computer and use it in GitHub Desktop.
dls for backup!
#
# Backup of mysql, files, whatever...
#
# example 1
backup.start do
new :mysql => {:host => '0.0.0.0', :user => 'root', :password => 'mypass'}
new :mysql => {:host => '0.0.0.0', :user => 'root', :password => 'mypass'}
new :archive => {:host => '0.0.0.0', :user => 'root', :password => 'mypass', :remote_file => ''}
end
# example 2
backup do
mysql do
server "my server name" do
user "user_server"
password "password"
tables [:table01, :table02, :table03]
end
end
files do
server "my server name" do
host "0.0.0.0"
user "user_server"
password "password"
remote_path "/remote/path/file/to/backup"
local_path "/local/path"
end
end
end
# example 3
backup :of => :mysql do
server :linode,
:host => '0.0.0.0',
:user => 'root',
:password => 'my_pass'
server :locaweb,
:host => '0.0.0.0',
:user => 'root',
:password => 'my_pass'
#
# Updated, based on comments
#
backup do
to do
remote_path '/path/to/remote/save/backup'
host '0.0.0.0'
user 'user_server'
password 'password'
end
mysql do
server 'blabla' do
host '0.0.0.0'
user 'root'
password 'my_root_password'
database 'server_database'
end
server 'bleble' do
host '0.0.0.0'
user 'root'
password 'my_root_password'
database 'server_database'
end
end
archive do
to do
local_path '/path/to/local/save/backup'
end
remote 'blublue' do
host '0.0.0.0'
user 'root'
password 'root_password'
files '/path/to/files'
end
local 'misc' do
files '/home/jtadeulopes/www/*.rb'
end
end
end
@kurko
Copy link

kurko commented Dec 24, 2010

Nice DSL. What's your idea?

Just thought of something:

backup :of => :mysql do

from :linode,
:host...
:user...

to :locaweb,
:host...
:user...

You could use multiple from() and to() too.

@jtadeulopes
Copy link
Author

My idea is to create a new DLS for backup.

There are alternatives, but no watch 100% of what I need. So I thought of making my own =)

Thanks!

@kurko
Copy link

kurko commented Dec 24, 2010

Keep it up. When you start the project (if it's opensource), pass on the repo address ;)

@cassiomarques
Copy link

I would discard example 1 since it uses new which is a reserved word. Even if there was a way to override it, it would become too confuse for my tastes.

I think the example 2 is better. I like the idea of using methods instead of a hash (looks like the Rails 3 routing API).

@lucascaton
Copy link

It looks great, congrats Jésus!

@jtadeulopes
Copy link
Author

Thanks Lucas!

Cássio,
I agree with you, the example 1 is a pretty ugly :( The idea of using methods makes the code more beautiful!

@renato-zannon
Copy link

Hey, congrats for the idea! :]
I personally think that example 3 is the easiest read, and seems the least verbose.
Oh, and example 2 is really RSpec-like! Which is a good thing considering how many people are used to it's sintax.
Great work! I'm looking forward into watching your repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment