aboutsummaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2018-05-19 08:23:48 -0300
committerSilvio Rhatto <rhatto@riseup.net>2018-05-19 08:23:48 -0300
commit1ef54f8773d5d3d6cf749c482dee42ec5bb26cd1 (patch)
treefccd7f6bb3a6502b48725c1727cad4a7bc787814 /templates
parentcfe68b9c2da2ff48171e2bbdb8988b92f7f41ee1 (diff)
downloadpuppet-backup-1ef54f8773d5d3d6cf749c482dee42ec5bb26cd1.tar.gz
puppet-backup-1ef54f8773d5d3d6cf749c482dee42ec5bb26cd1.tar.bz2
Use backup::params at backup::borg
Diffstat (limited to 'templates')
-rw-r--r--templates/borg.sh.erb80
1 files changed, 34 insertions, 46 deletions
diff --git a/templates/borg.sh.erb b/templates/borg.sh.erb
index 3eddd87..b37ab40 100644
--- a/templates/borg.sh.erb
+++ b/templates/borg.sh.erb
@@ -26,14 +26,14 @@ fi
# Initialize
if ! ssh $SSH_SERVER -p $SSH_PORT test -f /var/backups/remote/$HOSTNAME/borg/config; then
- info "Initializing borg repository at ssh://$SSH_SERVER:$SSH_PORT//var/backups/remote/$HOSTNAME/borg..."
+ info "Initializing borg repository at ssh://$SSH_SERVER:$SSH_PORT//var/backups/remote/$HOSTNAME/borg..."
borg init --encryption=<%= @encryption %> ssh://$SSH_SERVER:$SSH_PORT//var/backups/remote/$HOSTNAME/borg
- init_exit=$?
+ init_exit=$?
- if [ "$init_exit" != "0" ]; then
- fatal "Error initializing repository"
- fi
+ if [ "$init_exit" != "0" ]; then
+ fatal "Error initializing repository"
+ fi
fi
# Backup the most important directories into an archive named after
@@ -41,41 +41,29 @@ fi
info "Starting backup..."
-borg create \
- --verbose \
- --filter AME \
- --list \
- --stats \
- --show-rc \
- --compression lz4 \
- --exclude-caches \
- --exclude '/home/*/.cache/*' \
- --exclude '/var/cache/*' \
- --exclude '/var/tmp/*' \
- --exclude '/var/backups/remote' \
- --exclude '/var/backups/duplicity' \
- --exclude '/var/backups/restore' \
- --exclude '/var/cache' \
- --exclude '/var/vservers' \
- --exclude '/var/chroot' \
- --exclude '/root/.cache' \
- --exclude '/var/lib/dpkg' \
- --exclude '/var/lib/apt' \
- --exclude '/var/lib/aptitude' \
- --exclude '/var/sites/backups' \
- --exclude '/var/data/crypt' \
- --exclude '/var/data/backups' \
- --exclude '/var/data/cache' \
- ::'{hostname}-{now}' \
- /etc \
- /home \
- /root \
- /var \
-
- backup_exit=$?
+borg create \
+ --verbose \
+ --filter AME \
+ --list \
+ --stats \
+ --show-rc \
+ --compression lz4 \
+ --exclude-caches \
+ --exclude '/home/*/.cache/*' \
+ --exclude '/var/cache/*' \
+ --exclude '/var/tmp/*' \
+<% @exclude_unencrypted.each do |del| -%>
+ --exclude <%= del %> \
+<% end -%>
+ ::'{hostname}-{now}' \
+<% @include_unencrypted.each do |add| -%>
+ <%= add %> \
+<% end -%>
+
+ backup_exit=$?
if [ "$backup_exit" != "0" ]; then
- fatal "Error creating snapshot"
+ fatal "Error creating snapshot"
fi
info "Pruning repository..."
@@ -85,18 +73,18 @@ info "Pruning repository..."
# limit prune's operation to this machine's archives and not apply to
# other machines' archives also:
-borg prune \
- --list \
- --prefix '{hostname}-' \
- --show-rc \
+borg prune \
+ --list \
+ --prefix '{hostname}-' \
+ --show-rc \
--keep-daily <%= @keepdaily %> \
--keep-weekly <%= @keepweekly %> \
--keep-monthly <%= @keepmonthly %> \
- prune_exit=$?
+ prune_exit=$?
if [ "$prune_exit" != "0" ]; then
- fatal "Error pruning repository"
+ fatal "Error pruning repository"
fi
# use highest exit code as global exit code
@@ -104,12 +92,12 @@ fi
#
#if [ ${global_exit} -eq 1 ];
#then
-# info "Backup and/or Prune finished with a warning"
+# info "Backup and/or Prune finished with a warning"
#fi
#
#if [ ${global_exit} -gt 1 ];
#then
-# info "Backup and/or Prune finished with an error"
+# info "Backup and/or Prune finished with an error"
#fi
#
#exit ${global_exit}