Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions lib/puppet/functions/borgbackup/noop_connection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ def scope.noop_value
end

def scope.lookupdefaults(type)
values = super(type)
values = super

# Create a new :noop parameter with the specified value (true/false) for our defaults hash
noop = Puppet::Parser::Resource::Param.new(
name: :noop,
value: noop_value,
source: source
source: source,
)

# Adding this default fixes a corner case with resource collectors
Expand Down
10 changes: 5 additions & 5 deletions spec/classes/borgbackup_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
{ configdir: '/etc/borgbackup',
ensure_ssh_directory: true,
ssh_key_res: {},
repos_defaults: {} }
repos_defaults: {}, }
end

shared_examples_for 'borgbackup class' do
Expand Down Expand Up @@ -48,7 +48,7 @@
let :params do
default_params.merge(
repos: { 'default' => { 'passphrase' => 'secret' } },
default_target: 'irgendwo'
default_target: 'irgendwo',
)
end

Expand All @@ -65,7 +65,7 @@
describe 'with non default configuration directory' do
let :params do
default_params.merge(
configdir: '/tmp/backupdir'
configdir: '/tmp/backupdir',
)
end

Expand All @@ -83,7 +83,7 @@
describe 'with create .ssh directory in default location' do
let :params do
default_params.merge(
ensure_ssh_directory: false
ensure_ssh_directory: false,
)
end

Expand All @@ -96,7 +96,7 @@
let :params do
default_params.merge(
ssh_key_define: 'file',
ssh_key_res: { '/etc/borgbackup/.ssh/uid' => { 'owner' => 'myowner' } }
ssh_key_res: { '/etc/borgbackup/.ssh/uid' => { 'owner' => 'myowner' } },
)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/classes/git_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{ packages: %w[git gnupg],
gpg_keys: {},
gpg_home: '/etc/borgbackup/.gnupg',
git_home: '/etc/borgbackup/git' }
git_home: '/etc/borgbackup/git', }
end

shared_examples 'borgbackup::git shared examples' do
Expand Down Expand Up @@ -69,7 +69,7 @@
context 'with remote git repo' do
let :params do
default_params.merge(
gitrepo: 'somewhere/gitrepo'
gitrepo: 'somewhere/gitrepo',
)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/classes/install_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
describe 'borgbackup::install' do
let :default_params do
{ packages: ['borgbackup'],
package_ensure: 'installed' }
package_ensure: 'installed', }
end

shared_examples 'borgbackup::install shared examples' do
Expand Down Expand Up @@ -34,7 +34,7 @@
let :params do
default_params.merge(
packages: ['backup-whatever'],
package_ensure: 'actual'
package_ensure: 'actual',
)
end

Expand Down
10 changes: 5 additions & 5 deletions spec/classes/server_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
authorized_keys_target: '/var/lib/borgbackup/authorized-keys',
authorized_keys_define: 'borgbackup::authorized_key',
authorized_keys: {},
authorized_keys_defaults: {} }
authorized_keys_defaults: {}, }
end

shared_examples 'borgbackup::server shared examples' do
Expand Down Expand Up @@ -54,7 +54,7 @@
context 'with non default backuproot' do
let :params do
default_params.merge(
backuproot: '/tmp/backupdir'
backuproot: '/tmp/backupdir',
)
end

Expand All @@ -64,7 +64,7 @@
context 'with not creating user' do
let :params do
default_params.merge(
user_ensure: false
user_ensure: false,
)
end

Expand All @@ -76,7 +76,7 @@
describe 'with authorized-keys' do
let :params do
default_params.merge(
authorized_keys: { 'firstkey' => { 'keys' => ['key'] } }
authorized_keys: { 'firstkey' => { 'keys' => ['key'] } },
)
end

Expand All @@ -100,7 +100,7 @@
let :params do
default_params.merge(
authorized_keys_define: 'file',
authorized_keys: { '/etc/borgbackup/.ssh/authorized-keys' => { 'owner' => 'myowner', 'group' => 'mygroup' } }
authorized_keys: { '/etc/borgbackup/.ssh/authorized-keys' => { 'owner' => 'myowner', 'group' => 'mygroup' } },
)
end

Expand Down
4 changes: 2 additions & 2 deletions spec/defines/archive_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
let :params do
default_params.merge(
archive_name: title,
reponame: 'myrepo'
reponame: 'myrepo',
)
end

Expand All @@ -59,7 +59,7 @@
default_params.merge(
archive_name: title,
reponame: 'anotherrepo',
do_prune: false
do_prune: false,
)
end

Expand Down
6 changes: 3 additions & 3 deletions spec/defines/authorized_key_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
restrict_to_repository: 'yes',
append_only: false,
restricts: ['restrict'],
env_vars: {} }
env_vars: {}, }
end

shared_examples 'borgbackup::authorized_key shared examples' do
Expand All @@ -33,7 +33,7 @@
default_params.merge(
reponame: title,
backuproot: 'mybackuproot',
target: 'mytarget'
target: 'mytarget',
)
end

Expand All @@ -47,7 +47,7 @@
reponame: title,
backuproot: 'mybackuproot',
target: 'mytarget',
keys: ['rsa mykey']
keys: ['rsa mykey'],
)
end

Expand Down
10 changes: 5 additions & 5 deletions spec/defines/repo_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
append_only: false,
icinga_old: 90_000,
crontab_define: 'cron',
crontabs: {} }
crontabs: {}, }
end

shared_examples 'borgbackup::repo shared examples' do
Expand Down Expand Up @@ -55,7 +55,7 @@
let(:title) { 'mytitle' }
let :params do
default_params.merge(
reponame: title
reponame: title,
)
end

Expand All @@ -73,7 +73,7 @@
let :params do
default_params.merge(
reponame: title,
archives: { 'arch' => {} }
archives: { 'arch' => {} },
)
end

Expand All @@ -90,7 +90,7 @@
let :params do
default_params.merge(
reponame: title,
crontab_define: ''
crontab_define: '',
)
end

Expand All @@ -108,7 +108,7 @@
'user' => 'someuser',
'hour' => 12,
'minute' => 42,
} }
} },
)
end

Expand Down
9 changes: 9 additions & 0 deletions templates/archive_create.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,15 @@ borg create \

backup_exit=$?

if [ ${backup_exit} -ne 0 ];
then
info "Backup Create of archive '<%= @archive_name %>' finished with exit code ${backup_exit}"
backup_summary="${backup_summary}\n * Archive '<%= @archive_name %>' finished with exit code ${backup_exit}"
if [ ${backup_exit} -gt ${global_exit} ]; then
global_exit=$backup_exit
fi
fi

# commands to run post backup creation:
<% @post_commands.each do | command | -%>
<%= command %>
Expand Down
9 changes: 9 additions & 0 deletions templates/archive_prune.erb
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,12 @@ borg prune \
<% end -%>

prune_exit=$?

if [ ${prune_exit} -ne 0 ];
then
info "Backup Prune of archive '<%= @archive_name %>' finished with exit code ${prune_exit}"
prune_summary="${prune_summary}\n * Archive '<%= @archive_name %>' finished with exit code ${prune_exit}"
if [ ${prune_exit} -gt ${global_exit} ]; then
global_exit=$prune_exit
fi
fi
13 changes: 6 additions & 7 deletions templates/repo_footer.erb
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
# use highest exit code as global exit code
global_exit=$(( backup_exit > prune_exit ? backup_exit : prune_exit ))

if [ ${global_exit} -eq 1 ];
then
info "Backup and/or Prune finished with a warning"
if [ "${backup_summary}" != '' ]; then
info "Some backups had non zero exit codes:"
echo $backup_summary
fi

if [ ${global_exit} -gt 1 ];
then
info "Backup and/or Prune finished with an error"
if [ "${prune_summary}" != '' ]; then
info "Some archive prunes had non zero exit codes:"
echo ${prune_summary}
fi

exit ${global_exit}
4 changes: 4 additions & 0 deletions templates/repo_header.erb
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ if [ "$CMD" != 'run' ]; then
return
fi

prune_summary=''
backup_summary=''
global_exit=0

# some helpers and error handling:
info() { printf "\n%s %s\n\n" "$( date )" "$*" >&2; }
trap 'echo $( date ) Backup interrupted >&2; exit 2' INT TERM
Expand Down
Loading