Skip to content

Instantly share code, notes, and snippets.

View ianling's full-sized avatar

Ian ianling

View GitHub Profile
@ianling
ianling / backup_user_setup.yml
Created December 9, 2015 22:03
Sets up a backup user with passwordless sudo. Sets up key-based ssh authentication automatically.
---
- name: Set up backup user to be used by Ansible
hosts: all
remote_user: <an existing user>
roles:
- yaegashi.blockinfile
tasks:
- name: Generate a unique key for this host
@ianling
ianling / backuppc_inc_backup.yml
Created December 9, 2015 22:01
Run an incremental backup using BackupPC
---
- name: Incrementally back up host using BackupPC
hosts: all
remote_user: backup
tasks:
- name: Back up the host
local_action: command /usr/share/backuppc/bin/BackupPC_dump -i {{ inventory_hostname }}
@ianling
ianling / backuppc_full_backup.yml
Last active December 9, 2015 22:00
Runs a full backup of all hosts using BackupPC
---
#first, dump all MySQL databases and move them to a folder that gets backed up by BackupPC
- hosts: mysql
tasks:
- name: Create /backup/sql recursively
file: path=/backup/sql state=directory owner=backup group=backup mode=0766 recurse=yes
- name: Dump all MySQL databases, where applicable
shell: "/usr/bin/mysqldump --all-databases > /backup/sql/mysql.sql"