How do I Automate Website File Backups?
December 5, 2017
Automating Website File Backups
Admittedly, this is not the most exciting topic to some, but one of the greatest things about the ever-evolving tech landscape is how we continue to find ways to offload tasks that don’t need human attention to our machines. As web developers we find ourselves backing up site files and databases constantly. How can we automate this process to let the computer do the work for us? One solution is ansible. We can set up an ansible job in a backup.yml file like so:
---
- hosts: mysite
gather_facts: no
tasks:
- name: creating the zip file
command: zip -r mysite-files.zip .
- name: move the files from mysite to my computer
fetch:
src: mysite-files.zip
dest: tmp/mysite-files.zip
flat: yes