<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/snap_shot.rb</filename>
    </added>
    <added>
      <filename>lib/snap_shot/adapters/adapter.rb</filename>
    </added>
    <added>
      <filename>lib/snap_shot/adapters/mysql.rb</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -1,63 +1,92 @@
-Snapshot
+SnapShot
 ========
 
-Snapshot is a plugin that takes snapshots of your database and stores them so you can load them later. 
+SnapShot is a plugin that takes snapshots of your database and stores them so you can load them later. 
 
-I wrote Snapshot for a few purposes. While developing my apps, I found myself reseting my db all the time. After that, going through
+I wrote SnapShot for a few purposes. While developing my apps, I found myself reseting my db all the time. After that, going through
 and reconstructing the data from importing xml &amp; yml files, creating some users etc, I found that I needed snapshot I could load.
 I needed some ruby magic around mysqldump and importing. Of course you can use it for other things. It makes a handy backup utility as well.
 
 Requirements
 ======
-Snapshot only support mysql at the momement. I plan to add support for Postgres &amp; SQLite soon. Commands are execute inside a shell,
-so be sure you have mysqldump &amp; mysql in $PATH. I've not tested Snapshot on windows, so if you use windows, good luck. Let me know 
-how it goes. Snapshot has no other outside requirements
+SnapShot only support mysql at the momement. I plan to add support for Postgres &amp; SQLite soon. Commands are execute inside a shell,
+so be sure you have mysqldump &amp; mysql in $PATH. I've not tested SnapShot on windows, so if you use windows, good luck. Let me know 
+how it goes. SnapShot has no other outside requirements.
 
 Install
 =======
 Step 1
-		./script/plugin install git://github.com/Adman65/Snapshot.git
+		./script/plugin install git://github.com/Adman65/SnapShot.git
 Step2
-		mkdir /path/to/your/app/db/snapshots
+		rake snapshots:setup
 Step3
 		rake -T to see how to use snapshots
 
 Usage
 ======
 
-Taking a Snapshot
+Taking a SnapShot
 -------
 A snapshot is a dump of your database. If you're using mysql, snapshot uses mysqldump. 
 Taking a snapshot is easy. Use rake and pass it a file name to store
-			rake snapshots:take['AllUsers']
+			rake snapshots:take name=&quot;ALotOfProducts&quot;
 
 Voilla, you've just taken your first snapshot. This creates file in db/snaphots/all_users.snapshot
 Your snapshot is also tied to a schema version. You can only load snapshots when the snapshot schema and the current schema are the same. 
 So if you want to load a snapshot from the past, migrate down.
 
-Loading a Snapshot
+Loading a SnapShot
 -------
 Loading a snapshot is easy as well. Use the rake task with an argument. Forgot what snapshots you have?
 			rake snapshots:list
 Now load with
-			rake snapshots:load['AllUsers']
+			rake snapshots:load name=&quot;ALotOfProducts&quot;
 	
 Your database is restored in the exact state it was before. All ID's, records, and associations are present again.
 
-Deleting a Snapshot
+Deleting a SnapShot
 -------
 You may want to delete a snapshot. Use:
-			rake snapshots:destroy['AllUsers']
+			rake snapshots:destroy name=&quot;ALotOfProducts&quot;
 This will delete the file in db/snapshots
 
-Customizing Snapshot
+You may also want to delete all snapshots.
+			rake snapshots:destroy:all
+			
+Backups
 =======
+You may also uses SnapShot for backing up your database. It provides you with tools to backup your db, then restore it from the most recent snapshot.
+Back up your production database like this
+		rake snapshots:backups:take RAILS_ENV=production
 
-You may want to change the way Snapshot works. Say for example, you don't want to store your snapshots with your app, but have a different folder
+This creates a timestamped snapshot in app/db/snapshots/backups. You can view all your backups by doing:
+		rake snapshots:backups:list
+SnapShot places no limit to how many backups there are. You are only limited by your hard drive space.
+
+Oh no! You lost your database, but you've been regularly backing up your database. No prob, SnapShot to the resuce. SnapShot's restore capability
+drops the database, then creates a blank slate, migrates up the latests snapshot's version, and repopulates the db.  Nice huh?
+		rake snapshots:backups:restore RAILS_ENV=production
+And you're back in action! Painless.
+
+
+Customizing SnapShot
+=======
+
+You may want to change the way SnapShot works. Say for example, you don't want to store your snapshots with your app, but have a different folder
 else where. Simply create a symlink to snapshots
 		ln -s /var/snapshots me/my/app/db/snapshots
+		
+You may also want to save your backup snapshots in a different directory. This can be accomplished by symlinking as well
+		ln -s /var/myapp/backups /my/app/db/snapshots/backups
+
 
-Snapshots are taken using the current rails environment. If you want to take a snapshot of your production db for backup purposes use:
-		rake snapshots:take['BackUp'] RAILS_ENV=production
+Some Caveats
+=======
+SnapShot only saves things in your database. It doesn't save things like file uploads or other things you may have created outside of the database.
+It is up to you to handle those scenarios.
 
+TODO
+=========
+1. Add Support for Postgres &amp; SQLite
+2. Add S3 support
 Copyright (c) 2009 Adam Hawkins , released under the MIT license</diff>
      <filename>README.markdown</filename>
    </modified>
    <modified>
      <diff>@@ -1,2 +1,2 @@
 # Include hook code here
-require 'snapshot'
\ No newline at end of file
+require 'snap_shot'
\ No newline at end of file</diff>
      <filename>init.rb</filename>
    </modified>
    <modified>
      <diff>@@ -1,36 +1,74 @@
 namespace :snapshots do
+  desc &quot;Creates snapshot directories&quot;
+  task :setup =&gt; :environment do
+    path = File.join(RAILS_ROOT,'db','snapshots','backups')
+    FileUtils.mkdir_p(path) unless File.directory?(path)
+  end
+  
   desc &quot;List all snapshots&quot;
-  task :list do
-    Dir.glob(&quot;#{Snapshot::LOCATION}/*.snapshot&quot;).each { |file| puts File.basename(file,'.snapshot')}
+  task :list =&gt; :environment do
+    Dir.glob(File.join(SnapShot::LOCATION,&quot;/*.snapshot&quot;)).each { |file| puts File.basename(file,'.snapshot').camelcase}
   end
   
   desc &quot;Take a snapshot&quot;
-  task :take, :name, :needs =&gt; :environment do |task,args|
-    require 'snapshot'
-    result = Snapshot.take args.name
-    puts (result) ? 'Snapped!' : 'Snap Failed'
+  task :take =&gt; :environment do
+    result = SnapShot.take :file =&gt; ENV['name']
+    puts (result) ? 'Snapped' : 'Snap Failed'
   end
   
   desc &quot;Load a snapshot&quot;
-  task :load, :name, :needs =&gt; :environment do |task,args|
-    require 'snapshot'
-    result = Snapshot.load args.name
+  task :load =&gt; :environment do
+    result = SnapShot.load :file =&gt; ENV['name']
     puts (result) ? 'Loaded Snapshot' : 'Load Failed'
   end  
   
   desc &quot;Delete a snapshot&quot;
-  task :destroy, :name, :needs =&gt; :environment do |task, args|
-    require 'snapshot'
-    result = Snapshot.delete args.name
+  task :destroy =&gt; :environment do
+    result = SnapShot.destroy :file =&gt; ENV['name']
     puts (result) ? 'Deleted Snapshot' : 'Delete Failed'
   end
   
-  desc &quot;Takes a snapshot of the db and puts it in snapshots/backups&quot;
-  task :backup =&gt; :environment do
-    require 'snapshot'
-    path = File.join(RAILS_ROOT,'db','snapshots','backups')
-    FileUtils.mkdir(path) unless File.directory(path)
-    result = Snapshot.take &quot;backups/#{Time.now.strftime(&quot;%Y-%m-%d_%H-%M-%S&quot;)}&quot;
-    puts (result) ? 'Backed up!' : 'Backup Failed'
+  namespace :destroy do
+    desc &quot;Delete all snapshosts&quot;
+    task :all =&gt; :environment do
+      path = File.join(RAILS_ROOT,'db','snapshots','*.snapshot')
+      files = Dir.glob(path)
+      files.each do |file|
+        name = File.basename(file,'.snapshot').camelcase
+        puts &quot;Deleting #{name}...&quot;
+        result = SnapShot.destroy :file =&gt; name
+        puts (result) ? 'Deleted Snapshot' : 'Delete Failed'
+      end
+    end
+  end
+      
+  
+  namespace :backup do    
+    desc &quot;Takes a snapshot of the db and puts it in snapshots/backups&quot;
+    task :take =&gt; :environment do 
+      path = File.join(RAILS_ROOT,'db','snapshots','backups')
+      FileUtils.mkdir(path) unless File.directory?(path)
+      
+      result = SnapShot.take :file =&gt; Time.now.strftime(&quot;%Y-%m-%d-%H-%M-%S&quot;), :path =&gt; path
+      puts (result) ? 'Backed up!' : 'Backup Failed'
+    end
+    
+    desc &quot;Restores your database from the most recent snapshot. If the schema is different, your db is reset and migrated up to snapshot version, then the snapshot is loaded.&quot;
+    task :restore =&gt; :environment do
+      path = File.join(RAILS_ROOT,'db','snapshots','backups')
+      file = Dir.glob(File.join(path,&quot;*.snapshot&quot;)).last
+      file = File.basename(file,'.snapshot')
+      result = SnapShot.restore :file =&gt; file, :path =&gt; path
+      puts (result) ? 'Restored!' : 'Restore Failed'      
+    end
+  
+    desc &quot;Lists all backup snapshots&quot;    
+    task :list =&gt; :environment do 
+       Dir.glob(File.join(SnapShot::LOCATION,&quot;backups&quot;,&quot;*.snapshot&quot;)).each do |file|
+         parts = File.basename(file,'.snapshot').split('_')
+         parts = parts.map {|part| part.to_i}
+         puts DateTime.civil(parts[0],parts[1],parts[2],parts[3],parts[4],parts[5]).strftime(&quot;%Y-%m-%d %H:%M:%S&quot;)
+       end
+    end    
   end
 end
\ No newline at end of file</diff>
      <filename>tasks/snapshot_tasks.rake</filename>
    </modified>
  </modified>
  <removed type="array">
    <removed>
      <filename>lib/snapshot.rb</filename>
    </removed>
    <removed>
      <filename>lib/snapshot/adapters/adapter.rb</filename>
    </removed>
    <removed>
      <filename>lib/snapshot/adapters/mysql.rb</filename>
    </removed>
    <removed>
      <filename>lib/snapshot/errors.rb</filename>
    </removed>
  </removed>
  <parents type="array">
    <parent>
      <id>cda43b1a983c68fbe0645ffcd91eb1e85bfea707</id>
    </parent>
  </parents>
  <author>
    <name>Adman65</name>
    <email>Adman1965@gmail.com</email>
  </author>
  <url>http://github.com/Adman65/Snapshot/commit/e5f712644a1ab0076223916b42b048d21333d924</url>
  <id>e5f712644a1ab0076223916b42b048d21333d924</id>
  <committed-date>2009-06-30T01:01:01-07:00</committed-date>
  <authored-date>2009-06-30T01:01:01-07:00</authored-date>
  <message>Version 0.2
Reworked the rake task to feel like other tasks
Created a functional backup utility
Added some output to take/load/restore to give the user an idea of what's going on
Added some extra funcionality to the rake task</message>
  <tree>db31b18ce4f08448a93c27c7b766764b7b74dadd</tree>
  <committer>
    <name>Adman65</name>
    <email>Adman1965@gmail.com</email>
  </committer>
</commit>
