Skip to content

Commit

Permalink
added ondemand backup scripts for each client
Browse files Browse the repository at this point in the history
  • Loading branch information
kaimi committed Oct 15, 2013
1 parent b95774f commit b8de017
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 0 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,25 @@ Usage
-----

### recipes

#### rdiff-backup::default

Used in the other recipes. Do not call directly.

#### rdiff-backup::client

Sets up the client (= host to be backed up) side.

#### rdiff-backup::server

Sets up the server (= host to save backups to) side.

This will do things: if enabled, a cron job is created that backs up all
configured rdiff-backup clients, and scripts to run on demand backups of each
single client.

###definitions

#### backup\_path
`backup_path "/var/lib/mailman"`

Expand Down
17 changes: 17 additions & 0 deletions recipes/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
user u
group u
end
directory "#{d}/ondemand" do
user u
group u
end

cookbook_file "#{d}/.ssh/id_rsa" do
source k
Expand All @@ -36,6 +40,19 @@

clients.each do |c|
ssh_known_hosts_entry c['fqdn']

# create ondemand backup script
if c['dirs'] != nil then
template "#{d}/ondemand/#{c['fqdn']}.sh" do
source "ondemand.sh.erb"
user u
group u
mode 0750
variables ({
:c => c
})
end
end
end

template "#{d}/backup.sh" do
Expand Down
17 changes: 17 additions & 0 deletions templates/default/ondemand.sh.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash
#
# backup script generated by chef for <%= node.fqdn %>
# this script does an on demand backup of
# <%= @c['fqdn'] %>.
#
# DO NOT EDIT - manual edits WILL be lost
#

if [ -f <%= node['rdiff-backup']['cron']['lockfile'] %> ] ; then
echo "lock file present; aborting backup" >&2
exit 1
fi

ssh <%= @c['fqdn'] %> 'find <%= node['rdiff-backup']['etc_dir'] %>/pre.d -type f -exec {} \;'
rdiff-backup --print-statistics --remote-schema 'ssh -C %s "sudo /usr/bin/rdiff-backup --server --restrict-read-only /"' <% @c['dirs'].each do |d,w| %> --include <%= d %> <% end %> --exclude / <%= @c['fqdn'] %>::/ <%= node['rdiff-backup']['backup_dir'] %>/<%= @c['fqdn'] %>
ssh <%= @c['fqdn'] %> 'find <%= node['rdiff-backup']['etc_dir'] %>/post.d -type f -exec {} \;'

0 comments on commit b8de017

Please sign in to comment.