• Stars
    star
    150
  • Rank 247,323 (Top 5 %)
  • Language
    Shell
  • License
    MIT License
  • Created over 10 years ago
  • Updated over 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Ansible role to backup files, databases

Stouts.backup

Build Status Galaxy

Ansible role which manage backups. Support file backups, postgresql, mysql, mongo db backups.

Variables

The role variables and default values.

backup_enabled: yes             # Enable the role
backup_remove: no               # Set yes for uninstall the role from target system
backup_cron: yes                # Setup cron tasks for backup

backup_user: root               # Run backups as user
backup_group: "{{backup_user}}"

backup_home: /etc/duply         # Backup configuration directory
backup_work: /var/duply         # Working directory

backup_duplicity_ppa: ppa:duplicity-team/ppa  # Set empty for skipping PPA addition
backup_duplicity_pkg: duplicity
backup_duplicity_version:       # Set duplicity version

# Logging
backup_logdir: /var/log/duply   # Place where logs will be keepped
backup_logrotate: yes           # Setup logs rotation

# Posgresql
backup_postgres_user: postgres
backup_postgres_host: ""

# Mysql
backup_mysql_user: mysql
backup_mysql_pass: ""

backup_profiles: []           # Setup backup profiles
                              # Ex. backup_profiles:
                              #       - name: www               # required param
                              #         schedule: 0 0 * * 0     # if defined enabled cronjob
                              #         source: /var/www
                              #         max_age: 10D
                              #         target: s3://my.bucket/www
                              #         params:
                              #           - "BEST_PASSWORD={{ best_password }}"
                              #         exclude:
                              #           - *.pyc
                              #       - name: postgresql
                              #         schedule: 0 4 * * *
                              #         action: restore         # Choose action: backup/restore (default is backup)
                              #         source: postgresql://db_name
                              #         target: s3://my.bucket/postgresql

# Default values (overide them in backup profiles bellow) 
# =======================================================
# (every value can be replaced in jobs individually)

# GPG
backup_gpg_key: disabled
backup_gpg_pw: ""
backup_gpg_opts: ''

# TARGET
# syntax is
#   scheme://[user:password@]host[:port]/[/]path
# probably one out of
#   file://[/absolute_]path
#   ftp[s]://user[:password]@other.host[:port]/some_dir
#   hsi://user[:password]@other.host/some_dir
#   cf+http://container_name
#   imap[s]://user[:password]@host.com[/from_address_prefix]
#   rsync://user[:password]@other.host[:port]::/module/some_dir
#   rsync://[email protected][:port]/relative_path
#   rsync://[email protected][:port]//absolute_path
#   # for the s3 user/password are AWS_ACCESS_KEY_ID/AWS_SECRET_ACCESS_KEY
#   s3://[user:password]@host/bucket_name[/prefix]
#   s3+http://[user:password]@bucket_name[/prefix]
#   ssh://user[:password]@other.host[:port]/some_dir
#   tahoe://alias/directory
#   webdav[s]://user[:password]@other.host/some_dir
backup_target: 'file:///var/backup'
# optionally the username/password can be defined as extra variables
backup_target_user:
backup_target_pass:

# Time frame for old backups to keep, Used for the "purge" command.  
# see duplicity man page, chapter TIME_FORMATS)
backup_max_age: 1M

# Number of full backups to keep. Used for the "purge-full" command. 
# See duplicity man page, action "remove-all-but-n-full".
backup_max_full_backups: 1

# forces a full backup if last full backup reaches a specified age
backup_full_max_age: 1M

# set the size of backup chunks to VOLSIZE MB instead of the default 25MB.
backup_volsize: 50

# verbosity of output (error 0, warning 1-2, notice 3-4, info 5-8, debug 9)
backup_verbosity: 3

backup_exclude: [] # List of filemasks to exlude

Usage

Add Stouts.backup to your roles and set variables in your playbook file.

Example:

- hosts: all

  roles:
    - Stouts.backup

  vars:
    backup_target_user: aws_access_key
    backup_target_pass: aws_secret
    backup_profiles:

    # Backup file path
    - name: uploads                               # Required params
        schedule: 0 3 * * *                       # At 3am every day
        source: /usr/lib/project/uploads
        target: s3://s3-eu-west-1.amazonaws.com/backup.backet/{{inventory_hostname}}/uploads

    # Backup postgresql database
    - name: postgresql
        schedule: 0 4 * * *                       # At 4am every day
        source: postgresql://project              # Backup prefixes: postgresql://, maysql://, mongo://
        target: s3://s3-eu-west-1.amazonaws.com/backup.backet/{{inventory_hostname}}/postgresql
        user: postgres

Manage backups manually

Run backup for profile uploads manually:

$ duply uploads backup

Load backup for profile postgresql from cloud and restore database (logged as postgres user)

$ duply postgresql restore

Also see duply usage

License

Licensed under the MIT License. See the LICENSE file for details.

Feedback, bug-reports, requests, ...

Are welcome!

If you wish to express your appreciation for the role, you are welcome to send a postcard to:

Kirill Klenov
pos. Severny 8-3
MO, Istra, 143500
Russia

More Repositories

1

Stouts.openvpn

Ansible role to install and configure OpenVPN server
Jinja
287
star
2

Stouts.mongodb

Ansible role which manage MongoDB
Shell
76
star
3

Stouts.grafana

Ansible role which Installs and setups Grafana metrics dashboard
Makefile
54
star
4

Stouts.jenkins

Ansible role which manage Jenkins CI
Makefile
41
star
5

Stouts.sentry

Ansible role which manage Sentry
Python
40
star
6

Stouts.iptables

Ansible role which manage iptables rules
Shell
27
star
7

Stouts.nginx

Ansible role which simple manage nginx
Shell
17
star
8

Stouts.postfix

Ansible role which manage postfix
Makefile
17
star
9

Stouts.python

Ansible role which manage python (pip, virtualenv)
Python
16
star
10

Stouts.elasticsearch

Ansible role for Elasticsearch
Shell
15
star
11

Stouts.django

Ansible role for Django projects
15
star
12

Stouts.collectd

Ansible role to install and configure Collectd
Makefile
14
star
13

Stouts.wale

Ansible role which to perform continuous archiving of PostgreSQL WAL files
Shell
12
star
14

Stouts.supervisor

Ansible role which manage supervisor
Shell
12
star
15

Stouts.timezone

Ansible role which manage timezone
Makefile
10
star
16

Stouts.sudo

Manage sudoers
Makefile
9
star
17

Stouts.limits

Ansible role which manage system limis.
Makefile
9
star
18

Stouts.rabbitmq

Ansible role which manage RabbitMQ
Makefile
8
star
19

Stouts.redis

Ansible role which manage redis
HTML
7
star
20

Stouts.hostname

Ansible role for hostname managing
Makefile
7
star
21

Stouts.apt

Ansible role which manages apt
Shell
7
star
22

Stouts.celery

Ansible role wich manage celery
Makefile
7
star
23

Stouts.wsgi

Ansible role to setup and run WSGI applications
Shell
7
star
24

Stouts.users

Manage users and groups
Makefile
6
star
25

Stouts.nodejs

Ansible role which manage nodejs and npm
Shell
6
star
26

Django-application

Deploy Django application with ansible
Python
5
star
27

Stouts.deploy

Ansible role (just create base directories and define base variables)
5
star
28

Stouts.openssh

Ansible role which installs and setups OpenSSH (client and server)
Makefile
4
star
29

Stouts.graphite-api

Ansible role to install and configure Graphite API service
Shell
3
star
30

Stouts.source

Ansible role for get application source code from git or mercurial repositoires
Makefile
3
star
31

Stouts.foundation

Just proxy to some ansibles recipes
3
star
32

Stouts.notify

Ansible role wich send email notify when doing provision
Makefile
2
star
33

Stouts.ntp

Ansible role to install and setup NTP
Shell
2
star
34

Stouts.ruby

There is an Ansible role which installs ruby and ruby gems.
Makefile
2
star
35

Stouts.locale

Ansible role which manage system locales
Makefile
2
star
36

Stouts.logstash

Ansible role to install and configure Logstash
Shell
2
star
37

Stouts.denyhosts

Ansible role which manage Denyhosts
Python
2
star
38

Stouts.resources

Ansible role (copy files from your inventory directory to remote server)
Makefile
1
star
39

Stouts.ansible

Install and configure Ansible
Shell
1
star
40

Stouts.statsd

Ansible role to install and configure Statsd
Shell
1
star
41

Stouts.kibana

Ansible role to install and configure Elasticsearch Kibana
Makefile
1
star
42

Stouts.docker-backup

Ansible role to backup docker volumes
Makefile
1
star
43

Stouts.yum

Ansible role which manages Yum package manager
Makefile
1
star
44

Stouts.heka

Ansible role which manage Mozilla Heka
Makefile
1
star
45

Stouts.graphite-beacon

Ansible role to install and configure Graphite-beacon (alerting dashboard)
Makefile
1
star
46

Stouts.docker-registry

Ansible role to setup and run docker-registry
Shell
1
star
47

Stouts.memcached

Ansible role which manages Memcached
Makefile
1
star
48

Stouts.pull

Ansible role which manage ansible-pull
Shell
1
star