-
-
Save jtadeulopes/753877 to your computer and use it in GitHub Desktop.
# | |
# 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 |
Keep it up. When you start the project (if it's opensource), pass on the repo address ;)
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).
It looks great, congrats Jésus!
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!
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
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!