<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>Capfile</filename>
    </added>
    <added>
      <filename>config/deploy.rb</filename>
    </added>
    <added>
      <filename>public/life/.htaccess</filename>
    </added>
    <added>
      <filename>public/work/.htaccess</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -12,14 +12,23 @@ class DB
     run &quot;mysqladmin -u#{@user} -p#{@pass} -h#{@host} create #{db}&quot;
   end
   
-  def self.import_sql(file, db)
+  def self.import_sql(db, file)
     run &quot;mysql -u#{@user} -p#{@pass} -h#{@host} #{db} &lt; #{file}&quot;
   end
   
-  def self.import_sql_gz(file, db)
+  def self.import_sql_gz(db, file)
     run &quot;gunzip -c #{file} | mysql -u#{@user} -p#{@pass} -h#{@host} #{db}&quot;
   end
   
+  def self.export_sql_gz(db, name)
+    file = Time.now.strftime &quot;#{name}-%Y%m%d%H%M.sql&quot;
+    run &quot;mysqldump -u#{@user} -p#{@pass} -h#{@host} #{db} &gt; #{file}&quot;
+    run &quot;gzip -f #{file}&quot;
+    Dir.chdir(File.dirname(name)) do
+      run &quot;ln -s -f #{File.basename(file)}.gz #{File.basename(name)}-latest.sql.gz&quot;
+    end
+  end    
+  
   def self.run(cmd, options = {})
     puts cmd
     output = `#{cmd}`.strip
@@ -33,11 +42,6 @@ task :init do
   DB.init
 end
 
-task :install =&gt; :init do
-  `open http://localhost/work/wp-admin/install.php`
-  `open http://localhost/life/wp-admin/install.php`
-end
-
 namespace :db do
   task :setup =&gt; :init do
     DB.create_database('stellsmi_wordpress_life')
@@ -45,36 +49,33 @@ namespace :db do
   end
 
   task :load_mephisto =&gt; :init do
-    DB.create_database('mephisto_dev')
-    DB.import_sql('stellsmi_mephisto.sql', 'mephisto_dev')
+    DB.create_database('stellsmi_mephisto')
+    DB.import_sql('stellsmi_mephisto', 'stellsmi_mephisto.sql')
   end
   
-  task :backup do
-    type = ENV['TYPE'] || &quot;nightly&quot;
-    db, user, pass, host = load_database_settings
-    Dir.chdir(&quot;#{RAILS_ROOT}/db/backups&quot;) do
-      output = Date.today.strftime &quot;#{type}-%Y-%m-%d.sql&quot;
-
-      r &quot;mysqldump -u#{user} -p#{pass} -h#{host} #{db} &gt; #{output}&quot;
-      r &quot;gzip -f #{output}&quot;
-      r &quot;ln -s -f #{output}.gz nightly-latest.sql.gz&quot;
-    end
+  task :backup =&gt; :init do
+    DB.export_sql_gz(&quot;stellsmi_wordpress_life&quot;, &quot;db/backups/life&quot;)
+    DB.export_sql_gz(&quot;stellsmi_wordpress_work&quot;, &quot;db/backups/work&quot;)
   
     Rake::Task[&quot;db:rotate_backups&quot;].invoke
   end
 
-  task :restore_mephisto do
-    raise &quot;you must call production or development before this tag&quot; if DB.empty?
-    
-    db, user, pass, host = load_database_settings
-
-    Dir.chdir(&quot;#{RAILS_ROOT}/db/backups&quot;) do
-      input = &quot;nightly-latest.sql.gz&quot;
-      # r &quot;gunzip -f #{input}.gz&quot; if File.exist?(&quot;#{input}.gz&quot;) # symlinks are ignored, so we must force it
-
-      r &quot;mysqladmin -u#{user} -p#{pass} -h#{host} -f drop #{db}&quot;, :ignore_errors =&gt; true
-      r &quot;mysqladmin -u#{user} -p#{pass} -h#{host} create #{db}&quot;
-      r &quot;gunzip -c #{input} | mysql -u#{user} -p#{pass} -h#{host} #{db}&quot;
+  task :restore =&gt; :setup do    
+    DB.import_sql_gz(&quot;stellsmi_wordpress_life&quot;, &quot;db/backups/life-latest.sql.gz&quot;)
+    DB.import_sql_gz(&quot;stellsmi_wordpress_work&quot;, &quot;db/backups/work-latest.sql.gz&quot;)
+  end
+  
+  task :rotate_backups do
+    backups = Dir[&quot;db/backups/*.sql.gz&quot;].reject {|file| file =~ /latest/}.sort {|a, b| File.mtime(a) &lt;=&gt; File.mtime(b)}
+    backups[0..-10].each do |file| # everything but the last 10
+      puts &quot;deleting #{file}&quot;
+      FileUtils.rm(file)
+    end
+  end
+  
+  task :pull do
+    Dir.chdir(&quot;db/backups&quot;) do
+      DB.run &quot;scp stellsmi@onemanswalk.com:apps/blog/db/backups/*-latest.sql.gz db/backups/&quot;
     end
   end
 end
\ No newline at end of file</diff>
      <filename>Rakefile</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>6047b5e244ab76faaf17f3874f31250d896ce702</id>
    </parent>
  </parents>
  <author>
    <name>jeremylightsmith</name>
    <email>jeremy.lightsmith@gmail.com</email>
  </author>
  <url>http://github.com/jeremylightsmith/blog/commit/e53df96dd069066f3cdd750be03af4b59951fea1</url>
  <id>e53df96dd069066f3cdd750be03af4b59951fea1</id>
  <committed-date>2008-08-19T18:22:48-07:00</committed-date>
  <authored-date>2008-08-19T18:22:48-07:00</authored-date>
  <message>should be able to backup / restore</message>
  <tree>ef7c6505e885b2b719d0f5e7f5c8bbe8f3761fbf</tree>
  <committer>
    <name>jeremylightsmith</name>
    <email>jeremy.lightsmith@gmail.com</email>
  </committer>
</commit>
