Class: Backarch::Snapshot::Cassandra
Instance Method Summary
collapse
run, #snapshot_destination, #snapshot_name
Instance Method Details
#delete ⇒ Object
37
38
39
40
41
42
43
44
45
|
# File 'lib/backarch/snapshot/cassandra.rb', line 37
def delete
LOG.info("Removing snapshot #{snapshot_name}")
case Config.cassandra_version
when /\A0\.6\./
`find #{Config.input} -type d -wholename '*/snapshots/#{snapshot_name}' -exec rm -rf {} \\;`
else
`#{Config.nodetool} clearsnapshot -t #{snapshot_name}`
end
end
|
#request ⇒ Object
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# File 'lib/backarch/snapshot/cassandra.rb', line 4
def request
LOG.info "Requesting snapshot #{snapshot_name}"
case Config.cassandra_version
when /\A0\.6\./
`#{Config.nodetool} snapshot #{snapshot_name}`
`find #{Config.input} -type f -wholename '*/backups/*' -exec rm {} \\; 2>/dev/null`
`for snapshot in \`find #{Config.input} -type d -wholename '*/snapshots/*-#{snapshot_name}'\`; do basedir=\`dirname $snapshot\`; rm -rfv $basedir/#{snapshot_name}; mv $snapshot $basedir/#{snapshot_name}; done`
else
`#{Config.nodetool} snapshot -t #{snapshot_name} 2>/dev/null`
`find #{Config.input} -type f -wholename '*/backups/*' -exec rm {} \\;`
end
end
|
#sync ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/backarch/snapshot/cassandra.rb', line 19
def sync
$0 = "#{Config.program_name} snapshotter syncing #{snapshot_name}"
LOG.info 'Ready to sync snapshot'
snapshot_dirs = `find #{Config.input} -type d -wholename '*/snapshots/#{snapshot_name}'`.split(/\n/)
snapshot_dirs.map do |dir|
dest_dir = dir[%r{/data/(.+)/snapshots/}, 1]
prior_dir = Config.link_prior
link_prior = prior_dir ? "--link-dest=#{prior_dir}/#{dest_dir}" : ''
command = "rsync -ar --stats #{link_prior} #{dir}/ #{snapshot_destination}/#{dest_dir}"
LOG.debug command
FileUtils.mkdir_p "#{snapshot_destination}/#{dest_dir}"
FileUtils.chmod 0700, "#{snapshot_destination}/#{dest_dir}"
FileUtils.chown 'root', 'root', "#{snapshot_destination}/#{dest_dir}"
`#{command}`
end
end
|