# File lib/puppet/file_bucket/dipper.rb, line 32
32:   def backup(file)
33:     raise(ArgumentError, "File #{file} does not exist") unless ::File.exist?(file)
34:     contents = ::File.read(file)
35:     begin
36:       file_bucket_file = Puppet::FileBucket::File.new(contents, :bucket_path => @local_path)
37:       files_original_path = absolutize_path(file)
38:       dest_path = "#{@rest_path}#{file_bucket_file.name}#{files_original_path}"
39: 
40:       # Make a HEAD request for the file so that we don't waste time
41:       # uploading it if it already exists in the bucket.
42:       unless Puppet::FileBucket::File.head("#{@rest_path}#{file_bucket_file.checksum_type}/#{file_bucket_file.checksum_data}#{files_original_path}")
43:         file_bucket_file.save(dest_path)
44:       end
45: 
46:       return file_bucket_file.checksum_data
47:     rescue => detail
48:       puts detail.backtrace if Puppet[:trace]
49:       raise Puppet::Error, "Could not back up #{file}: #{detail}"
50:     end
51:   end