You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

80 lines
1.3 KiB

#!/bin/bash
## REQUIRES lxc-scripts, lxc
##
## Backup lxc
##
ln -sfv /opt/apps/lxc-scripts/etc/cron.hourly/* /etc/cron.hourly/
ln -sfv /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 <<EOF > /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 <<EOF > /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 <<EOF > /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