lib/s3backup/manager.rb in s3backup-0.7.01 vs lib/s3backup/manager.rb in s3backup-0.7.2
- old
+ new
@@ -74,11 +74,11 @@
next if /^\.+$/ =~ file
sub_dir.push(file) if File.directory?(dir+"/"+file)
end
exclude = ""
exclude = exclude + " --exclude=" + sub_dir.map{|d| shell_name(d)}.join(" --exclude=") if sub_dir.length != 0
- cmd = "(cd #{shell_name(File.dirname(dir))};tar -czvf #{shell_name(path)} #{exclude} #{shell_name(File.basename(dir))}" +
+ cmd = "(cd #{shell_name(File.dirname(dir))};tar -czvf #{shell_name(path)} #{exclude} -- #{shell_name(File.basename(dir))}" +
" > /dev/null 2>&1)"
S3log.debug(cmd)
system(cmd)
unless $?.success?
S3log.error("feiled #{cmd} execute. #{$?.inspect}")
@@ -190,18 +190,23 @@
old_tree = TreeInfo.new(@target.get(target_tree_name))
#前回と今回のファイル・ツリーを比較
diff_info = tree_info.diff(old_tree)
S3log.debug("diff_info=#{diff_info.inspect}")
+ tmp = Tempfile.open("tree_info.yml")
+ tmp.write(tree_info.dump_yaml)
+ tmp.close
dir_map = nil
if @resume
new_dir_map = tree_info.make_dir_map
old_dir_map = old_tree.make_dir_map
else
#メモリ節約のため開放
old_tree = nil
end
+ #メモリ節約のため開放
+ tree_info = nil
update_dir = diff_info[:directory][:add] + diff_info[:directory][:modify]
#更新されたディレクトリをアップロード
update_dir.each do |udir|
GC.start
store_directory(udir)
@@ -213,11 +218,13 @@
end
end
diff_info[:directory][:remove].each do |rm_dir|
delete_direcory(rm_dir)
end
+ tmp.open
#今回のファイル・ツリーをAWS S3に登録
- @target.post(target_tree_name,tree_info.dump_yaml)
+ @target.post(target_tree_name,tmp.read)
+ tmp.close(true)
end
def get_target_tree(dir)
base_dir = dir
tree_data = nil
before_base=""