infra/roles/backup/templates/rsnapshot.conf.j2

182 lines
5.5 KiB
Django/Jinja

#################################################
# rsnapshot.conf - rsnapshot configuration file #
#################################################
# #
# PLEASE BE AWARE OF THE FOLLOWING RULE: #
# #
# This file requires tabs between elements #
# #
#################################################
config_version 1.2
snapshot_root {{ rsnapshot_root }}
no_create_root 1
cmd_cp /bin/cp
cmd_rm /bin/rm
cmd_rsync /usr/bin/rsync
cmd_ssh /usr/bin/ssh
cmd_logger /usr/bin/logger
#cmd_rsnapshot_diff /usr/bin/rsnapshot-diff
#cmd_du /usr/bin/du
{% if sdfbackup %}
#cmd_preexec /path/to/preexec/script
#cmd_postexec /usr/local/bin/sdfbackup.sh
{% endif %}
#linux_lvm_cmd_lvcreate /sbin/lvcreate
#linux_lvm_cmd_lvremove /sbin/lvremove
#linux_lvm_cmd_mount /bin/mount
#linux_lvm_cmd_umount /bin/umount
retain alpha {{ retain_alpha }}
retain beta {{ retain_beta }}
retain gamma {{ retain_gamma }}
retain delta {{ retain_delta }}
# Verbose level, 1 through 5.
# 1 Quiet Print fatal errors only
# 2 Default Print errors and warnings only
# 3 Verbose Show equivalent shell commands being executed
# 4 Extra Verbose Show extra verbose information
# 5 Debug mode Everything
#
verbose 2
# Same as "verbose" above, but controls the amount of data sent to the
# logfile
loglevel 5
logfile /var/log/rsnapshot.log
lockfile /var/run/rsnapshot.pid
# By default, rsnapshot check lockfile, check if PID is running
# and if not, consider lockfile as stale, then start
#stop_on_stale_lockfile 0
# Default rsync args. All rsync commands have at least these options set.
#
#rsync_short_args -a
#rsync_long_args --delete --numeric-ids --relative --delete-excluded
# UserKnownHostsFile=
ssh_args -o ConnectTimeout=5
# Default arguments for the "du" program (for disk space reporting).
#du_args -csh
# If this is enabled, rsync wont span filesystem partitions within a
# backup point. This essentially passes the -x option to rsync.
# The default is 0 (off).
#
#one_fs 0
# The include and exclude parameters, if enabled, simply get passed directly
# to rsync. If you have multiple include/exclude patterns, put each one on a
# separate line.
#include ???
#include ???
#exclude ???
{% for path in rsnapshot_exclude %}
exclude {{ path }}
{% endfor %}
{% for username, user in userlist.items() %}
{% if user.backup|default(true) == false %}
exclude {{ user.home|default("/home/" + username) }}
{% endif %}
{% endfor %}
{% for username, user in systemuserlist.items() %}
{% if user.backup|default(true) == false %}
exclude {{ user.home|default("/var/lib/" + username) }}
{% endif %}
{% endfor %}
# The include_file and exclude_file parameters, if enabled, simply get
# passed directly to rsync.#
#include_file /path/to/include/file
#exclude_file /path/to/exclude/file
# If your version of rsync supports --link-dest, consider enabling this.
# This is the best way to support special files (FIFOs, etc) cross-platform.
# The default is 0 (off).
#
link_dest 0
# When sync_first is enabled, it changes the default behaviour of rsnapshot.
# Normally, when rsnapshot is called with its lowest interval
# (i.e.: "rsnapshot alpha"), it will sync files AND rotate the lowest
# intervals. With sync_first enabled, "rsnapshot sync" handles the file sync,
# and all interval calls simply rotate files. See the man page for more
# details. The default is 0 (off).
#
#sync_first 0
# If enabled, rsnapshot will move the oldest directory for each interval
# to [interval_name].delete, then it will remove the lockfile and delete
# that directory just before it exits. The default is 0 (off).
#
#use_lazy_deletes 0
# Number of rsync re-tries. If you experience any network problems or
# network card issues that tend to cause ssh to fail with errors like
# "Corrupted MAC on input", for example, set this to a non-zero value
# to have the rsync operation re-tried.
#
#rsync_numtries 0
{% for hostname in hostvars %}
{% set ssh_hostname = hostvars[hostname]["backup_ssh_hostname"] | default(hostname) -%}
# {{ hostname }}
{% for path in rsnapshot_default %}
{% if inventory_hostname == hostname %}
backup {{ path }} {{ hostname }}/
{% elif hostname in rsnapshot_exclude_hosts or hostvars[hostname]['rsnapshot_disabled']|default(false) %}
# not backing up: {{ hostname }}:{{ path }}
{% else %}
backup {{ rsnapshot_user }}@{{ hostname }}:{{ path }} {{ hostname }}/
{% endif %}
{% endfor %}
{% endfor %}
# deadspace backups from their origin
{% for origin in deadspace %}
{% for item in deadspace[origin] %}
{% if item.backup|default(false) == true %}
{% if inventory_hostname == origin %}
backup {{ item.path }}/ {{ origin }}/
{% else %}
backup {{ deadspace_user }}@{{ origin }}:{{ item.path }}/ {{ origin }}/
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
# my example:
# backup user@host:/home/ host/ exclude=foo/
{% for item in rsnapshot_extra_hosts|default([]) -%}
backup {{ item.user|default(rsnapshot_user) }}@{{ item.hostname }}:{{ item.path }}/ {{ item.hostname }}/
{% endfor %}
# examples from default file:
# LOCALHOST
# You must set linux_lvm_* parameters below before using lvm snapshots
#backup lvm://vg0/xen-home/ lvm-vg0/xen-home/
#backup_exec /bin/date "+ backup of example.com started at %c"
#backup root@example.com:/home/ example.com/ +rsync_long_args=--bwlimit=16,exclude=core
#backup root@example.com:/etc/ example.com/ exclude=mtab,exclude=core
#backup_exec ssh root@example.com "mysqldump -A > /var/db/dump/mysql.sql"
#backup root@example.com:/var/db/dump/ example.com/
#backup_exec /bin/date "+ backup of example.com ended at %c "