Posts

Showing posts from January, 2015

Cassandra: links to snapshots in one place

Use rsync with '-L' to copy elsewhere.

#!/usr/bin/ruby require 'fileutils' mybasedir = '/var/lib/cass' mydatadir = mybasedir + '/data' mysnapshotlinksdir = mybasedir + '/snapshots' FileUtils.remove_dir(mysnapshotlinksdir) if File.exists?(mysnapshotlinksdir) Dir.chdir mydatadir mysnapshotdirs = Dir.glob("**/*/") mysnapshotdirs = mysnapshotdirs.grep(/snapshots\/.+/) #p mysnapshotdirs mysnapshots = {} mysnapshotdirs.each do |mydir| mysnapshot = {} myparts = mydir.split('/') mysnapshot['keyspace'] = myparts[0] mysnapshot['cf'] = myparts[1] mysnapshot['tag'] = myparts[3] mysnapshot['linkdir'] = [mysnapshotlinksdir, mysnapshot['tag'], mysnapshot['keyspace']].join('/') mysnapshot['link'] = [mysnapshotlinksdir, mysnapshot['tag'], mysnapshot['keyspace'], mysnapshot['cf']].join('/') mysnapshot['target'…