Skip to content

Commit

Permalink
Merge pull request #7 from drybjed/fix-vanished
Browse files Browse the repository at this point in the history
Bypass issues with vanishing files during backups
  • Loading branch information
drybjed committed Jun 11, 2015
2 parents 2696a92 + b129a7e commit cfa2313
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 2 deletions.
14 changes: 14 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,20 @@
Changelog
=========

v0.1.6
------

*Released: 2015-06-11*

- Add ``rsnapshot_cmd_rsync`` variable which allows you to set the path to
a script executed during backup. [drybjed]

- Add ``rsync-no-vanished`` wrapper script, which bypasses an issue when `files
during long backups vanish`_ and the backup cycle is broken. It's set to be
run by default for all hosts, can be overriden per host. [drybjed]

.. _files during long backups vanish: https://bugzilla.samba.org/show_bug.cgi?id=3653

v0.1.5
------

Expand Down
6 changes: 6 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ rsnapshot_external_servers: []
rsnapshot_snapshot_root: '/var/cache/rsnapshot'


# .. envvar:: rsnapshot_cmd_rsync
#
# Main script executed by ``rsnapshot`` script to perform backups
rsnapshot_cmd_rsync: '/usr/local/lib/rsync-no-vanished'


# .. envvar:: rsnapshot_link_dest
#
# Enable --link-dest option in rsync commands
Expand Down
9 changes: 9 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
install_recommends: False
when: inventory_hostname in rsnapshot_clients

- name: Install rsync-no-vanished script
template:
src: 'usr/local/lib/rsync-no-vanished.j2'
dest: '{{ ansible_local.root.lib + "/rsync-no-vanished" }}'
owner: 'root'
group: 'root'
mode: '0755'
when: inventory_hostname in rsnapshot_clients

- name: Enforce rsnapshot root directory permissions
file:
path: '{{ rsnapshot_snapshot_root }}'
Expand Down
6 changes: 5 additions & 1 deletion templates/etc/rsnapshot/external-server/rsnapshot.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ cmd_cp /bin/cp
# rsync must be enabled for anything to work. This is the only command that
# must be enabled.
#
cmd_rsync /usr/bin/rsync
{% if (host.cmd_rsync is defined and host.cmd_rsync) %}
cmd_rsync {{ host.cmd_rsync }}
{% elif host.cmd_rsync is undefined %}
cmd_rsync {{ rsnapshot_cmd_rsync }}
{% endif %}

# Uncomment this to enable remote ssh backups over rsync.
#
Expand Down
6 changes: 5 additions & 1 deletion templates/etc/rsnapshot/server/rsnapshot.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,11 @@ cmd_cp /bin/cp
# rsync must be enabled for anything to work. This is the only command that
# must be enabled.
#
cmd_rsync /usr/bin/rsync
{% if (host.cmd_rsync is defined and host.cmd_rsync) %}
cmd_rsync {{ host.cmd_rsync }}
{% elif host.cmd_rsync is undefined %}
cmd_rsync {{ rsnapshot_cmd_rsync }}
{% endif %}

# Uncomment this to enable remote ssh backups over rsync.
#
Expand Down
21 changes: 21 additions & 0 deletions templates/usr/local/lib/rsync-no-vanished.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

# {{ ansible_managed }}

# Use this script instead of /usr/bin/rsync command to avoid issues with
# vanishing files.
# https://bugzilla.samba.org/show_bug.cgi?id=3653

IGNOREEXIT=24
IGNOREOUT='^(file has vanished: |rsync warning: some files vanished before they could be transferred)'

set -o pipefail

rsync "${@}" 2>&1 | (egrep -v "$IGNOREOUT" || true)
ret=$?

if [[ $ret == $IGNOREEXIT ]]; then
ret=0
fi

exit $ret

0 comments on commit cfa2313

Please sign in to comment.