fixes
This commit is contained in:
parent
611911c8b1
commit
90792e34f8
@ -8,12 +8,13 @@ set -e
|
||||
|
||||
cat > /etc/apt/sources.list <<EOF
|
||||
deb http://mirror.hetzner.de/debian/packages stretch main contrib non-free
|
||||
deb http://mirror.hetzner.de/debian/security stretch/updates main contrib non-free
|
||||
EOF
|
||||
apt update
|
||||
|
||||
|
||||
echo "Install important system tools."
|
||||
apt install -y htop ne iotop curl wget zsh figlet iptraf borgbackup
|
||||
apt install -y htop ne iotop curl wget zsh figlet iptraf borgbackup systemd-cron apticron logwatch unattended-upgrades
|
||||
|
||||
|
||||
echo "Use zsh!"
|
||||
@ -42,10 +43,6 @@ hostname -F /etc/hostname
|
||||
echo "Nice motd."
|
||||
figlet `hostname -f | sed 's/\./ \. /g'` > /etc/motd
|
||||
|
||||
|
||||
echo "Install system and security utils."
|
||||
apt install -y systemd-cron apticron logwatch unattended-upgrades
|
||||
|
||||
apt install -y ssmtp
|
||||
( exec ne /etc/ssmtp/* )
|
||||
|
||||
@ -56,6 +53,7 @@ for i in {4..6}; do
|
||||
systemctl disable getty@tty$i.service
|
||||
done
|
||||
|
||||
echo "setup systembackup"
|
||||
wget -q -O /usr/local/sbin/systembackup https://code.camijo.de/gmueller/server-scripts/raw/master/systembackup
|
||||
if [ ! -f /etc/systembackup.conf ] then
|
||||
cat >>/etc/systembackup.conf <<EOF
|
||||
|
25
systembackup
25
systembackup
@ -1,29 +1,30 @@
|
||||
#!/bin/bash
|
||||
|
||||
export PATH=/usr:/sbin:/usr/bin:/usr/sbin:/usr/local/sbin
|
||||
# ----------------------------------------------------------------------------
|
||||
# FUNCTIONS
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
cleanup() {
|
||||
if [ "y" == "$MYSQL" ]; then
|
||||
umount -f /var/lib/mysql-snapshot || true
|
||||
lvremove -f /dev/vg0/mysql-snapshot || true
|
||||
/bin/umount -f /var/lib/mysql-snapshot || true
|
||||
/sbin/lvremove -f /dev/vg0/mysql-snapshot || true
|
||||
fi
|
||||
}
|
||||
|
||||
mount_snapshot() {
|
||||
echo "mounting /var/lib/mysql-snapshot..."
|
||||
mkdir -p /var/lib/mysql-snapshot
|
||||
mount /dev/vg0/mysql-snapshot /var/lib/mysql-snapshot
|
||||
/bin/mkdir -p /var/lib/mysql-snapshot
|
||||
/bin/mount /dev/vg0/mysql-snapshot /var/lib/mysql-snapshot
|
||||
echo "mounted /var/lib/mysql-snapshot."
|
||||
}
|
||||
|
||||
create_snapshot() {
|
||||
echo "locking database..."
|
||||
mysql << EOF
|
||||
/usr/bin/mysql --defaults-extra-file=/root/.my.cnf << EOF
|
||||
FLUSH TABLES;
|
||||
FLUSH TABLES WITH READ LOCK;
|
||||
system lvcreate --snapshot -n mysql-snapshot -L16G /dev/vg0/mysql
|
||||
system /sbin/lvcreate --snapshot -n mysql-snapshot -L16G /dev/vg0/mysql
|
||||
UNLOCK TABLES;
|
||||
EOF
|
||||
echo "database locked"
|
||||
@ -35,7 +36,7 @@ EOF
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
if [ ! -f /etc/systembackup.conf ]; then
|
||||
echo "systembackup not configured"
|
||||
echo "systembackup not configured (/etc/systembackup.conf)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -69,7 +70,7 @@ fi
|
||||
# BACKUP
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
BORG_PASSPHRASE=$PASSPHRASE /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 borg create --stats -v \
|
||||
BORG_PASSPHRASE=$PASSPHRASE /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /usr/bin/borg create --stats -v \
|
||||
$REPOSITORY::'{hostname}-{now:%Y-%m-%d-%H}' \
|
||||
/ \
|
||||
--compression lzma \
|
||||
@ -91,12 +92,6 @@ BORG_PASSPHRASE=$PASSPHRASE /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 borg cre
|
||||
# PRUNE
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
BORG_PASSPHRASE=$PASSPHRASE /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 borg prune -v --list $REPOSITORY --prefix '{hostname}-' \
|
||||
BORG_PASSPHRASE=$PASSPHRASE /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /usr/bin/borg prune -v --list $REPOSITORY --prefix '{hostname}-' \
|
||||
--keep-hourly=6 --keep-daily=7 --keep-weekly=4 --keep-monthly=6
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# CLEANUP
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
cleanup
|
||||
|
Loading…
Reference in New Issue
Block a user