Giter Club home page Giter Club logo

apiscp-duplicity-rclone's Introduction

ApisCP backups: Duplicity and Rclone

This playbook is meant to run on a controller node (can be your own pc) in order to perform an automated backups configuration on your ApisCP nodes.

The playbook will configure Duplicity for the backups themselves, Rclone for remote backup transmission, systemd for the required services, timers and reboot guards.

Read more about:

Caveats

Rclone configuration requires you to initially use rclone to configure it on the controller node (Learn how โ†’). Then, you'll have to tell the playbook where to find the configuration and it's name, through the config.yml similar to what follows:

---
# where your rclone config is
rclone_config_source: '/home/yourname/.config/rclone/rclone.conf'
# the name of the remote connection you configured
rclone_config_section: 'google-backups'

Configuration

Create a config.yml file containing a similar configuration as described below, omit the defaults:

---
# where to store backups
backup_dir: '/home/backup'
# which cipher to use
backup_algo: 'AES256'
# which paths to back up
backup_directories: [
  '/home/virtual/site*/shadow',
  '/home/virtual/site*/info',
  '/var/log/mailer_table*',
  '/var/lib/mysql/mysql-grants*',
  '/var/lib/pgsql/*/backups'
]
# URL to be called on success
heartbeat_url: "https://betteruptime.com/api/v1/heartbeat/{{ heartbeat_id }}"
# your encryption password
backup_secret_passphrase: 'your-secure-password'
# where your rclone config is
rclone_config_source: '/home/yourname/.config/rclone/rclone.conf'
# the name of the remote connection you configured
rclone_config_section: 'google-backups'

Create an inventory.yml file containing the information of your ApisCP nodes (Learn how โ†’) as described below:

---
all:
  hosts:
    web1:
      # overriding global configuration
      rclone_config_section: 'eu-backups'
    web2:
      rclone_config_section: 'na-backups'

Usage

  1. Install Ansible.
    sudo yum install ansible
  2. Clone this repository to your local drive.
    git clone https://github.com/thundersquared/apiscp-duplicity-rclone.git ; cd apiscp-duplicity-rclone/
  3. Run playbook.
    ansible-playbook main.yml

How it works

This playbook creates installs duplicity and rclone on the servers in your inventory. It creates a systemd timer to invoke the related service that runs /usr/local/sbin/SystemBackup daily. It also installs a reboot guard, a unit that prevents system reboots during an ongoing backup.

When a backup starts, the reboot guard is enabled. Duplicity will be using the configuration name provided for rclone to mount and send the backups to the remote connection. When the backup ends, curl is used to call the heartbeat_url when set then the reboot guard is disabled.

Heartbeats

Heartbeats are used to notify backup job completion. You can add a heartbeat_url to your config.yml with a per-node unique ID such as heartbeat_id in your inventory.yml. Here's an example:

# config.yml
---
# where your rclone config is
rclone_config_source: '/home/yourname/.config/rclone/rclone.conf'
# the name of the remote connection you configured
rclone_config_section: 'google-backups'
# URL to be called on success
heartbeat_url: "https://betteruptime.com/api/v1/heartbeat/{{ heartbeat_id }}"
# inventory.yml
---
all:
  hosts:
    web1:
      heartbeat_id: 'web1-token-123456'
    web2:
      heartbeat_id: 'web2-token-123456'

The URLs that the script will be calling will then look something like:

# web1 will call:
https://betteruptime.com/api/v1/heartbeat/web1-token-123456
# web2 will call:
https://betteruptime.com/api/v1/heartbeat/web2-token-123456

apiscp-duplicity-rclone's People

Contributors

anatolinicolae avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.