From 7c83ad0b971714c14a96ac29d4113b36b0c7c59a Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Sun, 4 Apr 2021 07:41:22 +0200 Subject: [PATCH] new: [host] minimal host backup config Signed-off-by: Valentin Lab --- precise/host/hooks/install.d/70-0k.sh | 1 - precise/host/hooks/install.d/96-backup-lxc.sh | 70 +++++++++++++++++++ 2 files changed, 70 insertions(+), 1 deletion(-) diff --git a/precise/host/hooks/install.d/70-0k.sh b/precise/host/hooks/install.d/70-0k.sh index d3723f0..c2ef19c 100755 --- a/precise/host/hooks/install.d/70-0k.sh +++ b/precise/host/hooks/install.d/70-0k.sh @@ -225,7 +225,6 @@ rm -rf /var/cache/compose cat < /etc/default/datastore DATASTORE=/srv/datastore -SNAPSHOT_BACKUP=/var/backups/snapshot EOF cat < /etc/default/compose diff --git a/precise/host/hooks/install.d/96-backup-lxc.sh b/precise/host/hooks/install.d/96-backup-lxc.sh index ebf4908..d912f68 100755 --- a/precise/host/hooks/install.d/96-backup-lxc.sh +++ b/precise/host/hooks/install.d/96-backup-lxc.sh @@ -8,3 +8,73 @@ ln -sf /opt/apps/lxc-scripts/etc/cron.hourly/* /etc/cron.hourly/ ln -sf /opt/apps/lxc-scripts/etc/cron.daily/* /etc/cron.daily/ + + +if ! grep ^BACKUP_LXC_PATH= /etc/default/lxc >/dev/null 2>&1; then + echo "BACKUP_LXC_PATH=/var/backups/lxc" >> /etc/default/lxc +fi + + +if ! grep ^BACKUP_SNAPSHOT_PATH= /etc/default/datastore >/dev/null 2>&1; then + echo "BACKUP_SNAPSHOT_PATH=/var/backups/snapshot" >> /etc/default/datastore +fi + + +## +## Mirror dir's logrotate and rsyslog's entry +## + + +mkdir -p /etc/mirror-dir +cat < /etc/mirror-dir/config.yml +default: + sources: + - /etc + - /opt + - /root + - /var/log + - /var/lib/lxc + - /home + - /boot + - /srv + - /var/backups/lxc/latest + +/var/lib/lxc: + exclude: + - /*/rootfs +EOF + + +cat < /etc/rsyslog.d/mirror-dir.conf + +if \$programname == 'mirror-dir' then { + action(type="omfile" file="/var/log/mirror-dir.log") + stop +} + +EOF + +service rsyslog restart + + +cat < /etc/logrotate.d/mirror-dir.log +/var/log/mirror-dir.log +{ + weekly + missingok + dateext + dateyesterday + dateformat _%Y-%m-%d + extension .log + rotate 52 + compress + delaycompress + notifempty + create 640 root root + sharedscripts + postrotate + reload rsyslog >/dev/null 2>&1 || true + endscript +} + +EOF