An Ansible Role to install and configure rsanpshot.
Everybody needs a valid backup. As often stated: "no backup, no mercy".
This Ansible Role installs and configures rsnapshot.
- install packages
- configure rsnapshot
- create systemd service
- create systemd timers
Used Modules:
Install from Ansible Galaxy
ansible-galaxy install while_true_do.srv_rsnapshot
Install from Github
git clone https://github.com/while-true-do/ansible-role-srv_rsnapshot.git while_true_do.srv_rsnapshot
Dependencies:
For CentOS Systems, the EPEL repository must be enabled. You can achive this by running the while_true_do.rpo_epel Ansible Role.
ansible-galaxy install -r requirements.yml
---
# defaults/main.yml for rsnapshot
## Package Management
wtd_srv_rsnapshot_package: "rsnapshot"
# State can be present|latest|absent
wtd_srv_rsnapshot_package_state: "present"
## Configuration Management
# Below you can find some example configuration.
# You MUST define "retains: []" and "backup: []"
# Please consult man rsnapshot for more information or https://rsnapshot.org
wtd_srv_rsnapshot_conf: []
# version: 1.2
# snapshot_root: "/.snapshots/"
# no_create_root: 1
# cmd_cp: "/usr/bin/cp"
# cmd_rm: "/usr/bin/rm"
# cmd_rsync: "/usr/bin/rsync"
# cmd_ssh: "/usr/bin/ssh"
# cmd_logger: "/usr/bin/logger"
# cmd_du: "/usr/bin/du"
# cmd_rsnapshot_diff: "/usr/bin/rsnapshot-diff"
# cmd_preexec: ""
# cmd_postexec: ""
# linux_lvm_cmd_lvcreate: "/usr/sbin/lvcreate"
# linux_lvm_cmd_lvremove: "/usr/sbin/lvremove"
# linux_lvm_cmd_mount: "/usr/bin/mount"
# linux_lvm_cmd_umount: "/usr/bin/umount"
# retains:
# - name: "some name" # the name for the retains
# value: 15 # how many backups do want to keep
# time: "daily" # systemd timer time format
# enabled: true # define if the timer should be enabled (default true)
# verbose: 2
# loglevel: 3
# logfile: "/var/log/rsnapshot/rsnapshot.log"
# lockfile: "/var/run/rsnapshot.pid"
# stop_on_stale_lockfile: 0
# rsync_short_args: ""
# rsync_long_args: ""
# ssh_args: "-p 22"
# du_args: "-csh"
# one_fs: 0
# includes: [] # global include patterns
# excludes: [] # global exclude patterns
# include_files: [] # global include_files
# exclude_files: [] # global exclude_files
# link_dest: 0
# sync_first: 0
# use_lazy_deletes: 0
# rsync_numtries: 0
# linux_lvm_snapshotsize: "100M"
# linux_lvm_snapshotname: "rsnapshot"
# linux_lvm_vgpath: "/dev"
# linux_lvm_mountpath: "/path/to/mount/lvm/snapshot/during/backup"
# The backup list can take multiple statements
# backups:
# - comment: "" # useful, if you need a comment line
# - src: "/foo/" # define source and destination of your backups
# dest: "foo/"
# options: "" # you can backup specific options like excludes
# - script: "foo.sh" # define a script and a destination for a scripted backup
# dest: "foo/"
# - exec: "foo.sh" # Just run some command
Running Ansible Roles can be done in a playbook.
Doing daily backups of your localhost and keep them for 14 days.
---
- hosts: all
roles:
- role: while_true_do.rpo_epel
- role: while_true_do.srv_rsnapshot
wtd_srv_rsnapshot_conf:
retains:
- name: "daily"
value: 14
time: "daily"
enabled: true
backups:
- comment: "# LOCALHOST"
- src: "/home/"
dest: "localhost/"
- src: "/var/log"
dest: "localhost/"
- src: "/etc/"
dest: "localhost/"
This example does daily, weekly and monthly backups for localhost and example.com (via backup user).
- hosts: all
roles:
- role: while_true_do.rpo_epel
- role: while_true_do.srv_rsnapshot
wtd_srv_rsnapshot_conf:
retains:
- name: "daily"
value: 14
time: "daily"
- name: "weekly"
value: 8
time: "weekly"
- name: "monthly"
value: 12
time: "monthly"
backups:
- comment: "LOCALHOST"
- src: "/etc/"
dest: "localhost/"
- src: "/home/"
dest: "localhost/"
- src: "/var/log/"
dest: "localhost/"
- comment: "EXAMPLE.COM"
- src: "backup@example.com:/etc/"
dest: "example.com/"
- src: "backup@example.com:/home/"
dest: "example.com/"
- src: "backup@example.com:/var/log/"
dest: "example.com/"
- RedHat Testing is currently not possible in public, due to limitations in subscriptions.
- Some services and features cannot be tested properly, due to limitations in docker.
Most of the "generic" tests are located in the Test Library.
Ansible specific testing is done with Molecule.
Infrastructure testing is done with testinfra.
Automated testing is done with Travis CI.
Thank you so much for considering to contribute. We are very happy, when somebody is joining the hard work. Please fell free to open Bugs, Feature Requests or Pull Requests after reading the Contribution Guideline.
See who has contributed already in the kudos.txt.
This work is licensed under a BSD-3-Clause License.
- Site https://while-true-do.io
- Twitter https://twitter.com/wtd_news
- Code https://github.com/while-true-do
- Mail hello@while-true-do.io
- IRC freenode, #while-true-do
- Telegram https://t.me/while_true_do