# File lib/rhc-common.rb, line 831
  def self.snapshot_create(rhc_domain, namespace, app_name, app_uuid, filename, debug=false)

    ssh_cmd = "ssh #{app_uuid}@#{app_name}-#{namespace}.#{rhc_domain} 'snapshot' > #{filename}"
    puts "Pulling down a snapshot to #{filename}..."
    puts ssh_cmd if debug
    puts 

    begin

      if ! RHC::Helpers.windows?
        output = `#{ssh_cmd}`
        if $?.exitstatus != 0
          puts output
          puts "Error in trying to save snapshot.  You can try to save manually by running:"
          puts
          puts ssh_cmd
          puts
          return 1
        end
      else
        Net::SSH.start("#{app_name}-#{namespace}.#{rhc_domain}", app_uuid) do |ssh|
          File.open(filename, 'wb') do |file|
            ssh.exec! "snapshot" do |channel, stream, data|
              if stream == :stdout
                file.write(data)
              else
                puts data if debug
              end
            end
          end
        end
      end
    rescue Exception => e
      puts e.backtrace if debug
      puts "Error in trying to save snapshot.  You can try to save manually by running:"
      puts
      puts ssh_cmd
      puts
      return 1
    end
    true
  end