coopdevs / backups_role Goto Github PK
View Code? Open in Web Editor NEWBackups strategy for Coopdevs projects
Home Page: https://galaxy.ansible.com/coopdevs/backups_role
Backups strategy for Coopdevs projects
Home Page: https://galaxy.ansible.com/coopdevs/backups_role
ansible-lint Warnings:
./galaxy/downloads/tmpbe4jz3/meta/main.yml:1: [E701] Role info should contain platforms
--
it works at least with Ubuntu 16.04.6 LTS
Instead of having 3 templates rendering into 3 bash scripts that call each other,
use 3 templates that render into only 1 bash script. cron-main.sh.j2 should look like this:
# common code
set -e
function title {
...
}
# prepare tmp dir
...
# compile files to backup
{% include "backups_prepare.sh.j2" %}
# upload backups using restic
{% include "backups_upload.sh.j2" %}
# clean tmp dir
...
Then leave only one template
task in tasks/main.yml
.
Also remove task Ensure directory for backups temporary data exists , as it's redundant to cron_main.sh.j2
Complains:
Description
Task to clean old backups with restic has a weird schedule. It says “At 11:05 on every 5th day-of-month.” according to "crontab guru" and manpages.
If this is meant to run every 5 minutes, it should read */5 * * * *
Relevant code
https://github.com/coopdevs/backups-role/blob/bfdab61a8b88c7cee9ee608cdbebe94e02765a0d/tasks/main.yml#L32-L34
Discussion
We should discuss how often we call it. The removal itself restic says it's costly. Despite the date check may not be slow, I wouldn't risk.
And the time to do a new backup and remove oldest one should not be daylight (like 11:05), in my opinion.
Create a task to restore a backup or at least, to download backed up packs to the same server, like config tar.gz and the database dump.
The restic role we are using lacks this feature, but we can use restic with:
export RESTIC_REPOSITORY={{backups_role_bucket_url }}
export RESTIC_PASSWORD={{backups_role_restic_password }}
restic restore latest --target /tmp/restore
Sources:
However, we can do it easier. The restic role adds a helper for every restic repo with the credentials loaded in the environment, so that we could just do:
- name: Restore latest backup
command: {{ restic_install_path }}/restic-{{ backups_role_restic_repo_name }} restore latest --target {{ backups_role_restore_path }}
===== LINTING ROLE =====
yamllint Warnings:
./defaults/main.yml:38:1: [error] too many blank lines (1 > 0) (empty-lines)
the commit is about a wrapper script
While running a backup after coopdevs/timeoverflow-provisioning#130 the backup script didn't succeed. The script got copied, but missing an argument, with the following content:
sudo tar -czvf /opt/backups/.tmp/assets.tar.gz
which fails.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.