I have made a small script that makes a backup of
a subversion repository.. with outputfiles formatted as:
backup20050722_rev68.gz

But I wonder if there is a smarter way to determine what
the last revision?

--
Simon Strandgaard


require 'open3'

task :default => :svnbackup

task :svnbackup do
	repos = '/Users/simonstrandgaard/code/svnrepos'

	dummyfile = 'backuptmp'
	
	cmd = "svnadmin dump #{repos} | gzip -9 > #{dummyfile}"
	si, so, se = Open3.popen3(cmd) #do |stdin, stdout, stderr|
	si.close 

	se_res = ''
	so_res = ''
	t1 = Thread.start do
		while line=so.gets
			so_res << line
			puts "stdout: #{line}"
		end
	end
	t2 = Thread.start do
		while line=se.gets
			se_res << line
			puts "stderr: #{line}"
		end
	end
	t1.join
	t2.join
	so.close
	se.close
	
	#p so_res, se_res
	ary = se_res.scan(/Dumped\srevision\s(\d+)\./m)
	rev = '_rev' + ary.flatten.last
	
	#p rev
	filename = 'backup' + Time.now.strftime('%Y%m%d')
	filename += rev
	filename += '.gz'

	mv(dummyfile, filename)
end