You need to sign in or sign up before continuing.
Newer
Older
#!/bin/bash
# Copyright © 2019 Le Filament (<http://www.le-filament.com>)
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
mkdir -p /home/{{ host_user }}/versions
TODAY=`date +%F`
file="/home/{{ host_user }}/versions/{{ inventory_hostname|lower }}-docker.$TODAY"
latest_file="/home/{{ host_user }}/versions/{{ inventory_hostname|lower }}-docker.latest"
printf "DATE = $TODAY" > $file
printf "\n\n-- Docker version --\n" >> $file
/usr/bin/docker version >> $file
printf "\n\n-- List of containers --\n" >> $file
/usr/bin/docker ps -a >> $file
printf "\n\n-- List of images --\n" >> $file
/usr/bin/docker images --digests >> $file
printf "\n\n-- Disk usage (condensed) --\n" >> $file
/usr/bin/docker system df >> $file
printf "\n\n-- Disk usage (full) --\n" >> $file
/usr/bin/docker system df -v >> $file
printf "\n\n-- Usage Statistics --\n" >> $file
/usr/bin/docker stats -a --no-stream >> $file
cp $file $latest_file
chmod 644 $file $latest_file
{% for host in groups.backup_server %}
{% if host != inventory_hostname %}
sftp -P {{ default_sshd_port }} -o IdentityFile=/home/{{ host_user }}/.ssh/id_ed25519 {{ backup_sftp_user }}@{{ hostvars[host].ansible_host }} << COMMANDS
put $file {{ inventory_hostname|lower }}/
quit
COMMANDS