From 2a2533c367a22f3ae95fcada27ee15a8f5b5564d Mon Sep 17 00:00:00 2001 From: alex Date: Wed, 13 Oct 2021 00:38:55 -0400 Subject: [PATCH] backups: Consolidate dump logic into "dumpster" tool This tool combines the weekly and daily dumps into a single tool with the dump pattern: 0 (sundays / weekly cron) 1 2 3 4 5 6 7 (mon - sun, daily) The benefit here is that we can see what changed on a day-to-day basis (starting from the beginning of the week), which also minimizes the size of each dump. This comes at the cost of a full system rebuild taking potentially 7 restores (but in reality, we probably would just restore from 0 and grab select files for users...) While we're here, I also removed the dump's of /usr and /usr/local. Both are big (~1GB) and not worth storing (since we don't expect them to change _too_ much / we can always reinstall the packages which are backed up with /var/backups/pkglist). --- Makefile | 1 + etc/daily.local | 10 +--------- etc/weekly.local | 10 ++-------- usr/local/bin/dumpster | 11 +++++++++++ 4 files changed, 15 insertions(+), 17 deletions(-) create mode 100755 usr/local/bin/dumpster diff --git a/Makefile b/Makefile index 22b8b74..792f40c 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ FILES = /etc/httpd.conf \ /usr/local/bin/newrepo \ /usr/local/man/man1/newrepo.1 \ /usr/local/bin/wggen \ + /usr/local/bin/dumpster \ /usr/local/man/man8/wggen.8 \ /home/_soju/soju.cfg diff --git a/etc/daily.local b/etc/daily.local index 3c8b9de..701a6b4 100644 --- a/etc/daily.local +++ b/etc/daily.local @@ -1,10 +1,2 @@ ROOTBACKUP=1 - -BAKDIR="/bak/$(date +%F)" -mkdir -p "$BAKDIR" - -dump -1auf "$BAKDIR/root.dump.1" / -dump -1auf "$BAKDIR/home.dump.1" /home -dump -1auf "$BAKDIR/usr.dump.1" /usr -dump -1auf "$BAKDIR/usr-local.dump.1" /usr/local -dump -1auf "$BAKDIR/var.dump.1" /var +/usr/local/bin/dumpster diff --git a/etc/weekly.local b/etc/weekly.local index 026d0f4..b2ca454 100644 --- a/etc/weekly.local +++ b/etc/weekly.local @@ -1,8 +1,2 @@ -BAKDIR="/bak/$(date +%F)" -mkdir -p "$BAKDIR" - -dump -0auf "$BAKDIR/root.dump.0" / -dump -0auf "$BAKDIR/home.dump.0" /home -dump -0auf "$BAKDIR/usr.dump.0" /usr -dump -0auf "$BAKDIR/usr-local.dump.0" /usr/local -dump -0auf "$BAKDIR/var.dump.0" /var +# force a 0-level (full) dump +/usr/local/bin/dumpster 0 diff --git a/usr/local/bin/dumpster b/usr/local/bin/dumpster new file mode 100755 index 0000000..a1d2cfb --- /dev/null +++ b/usr/local/bin/dumpster @@ -0,0 +1,11 @@ +#!/bin/sh +# dumpster -- taking out the garbash with dump(8) + +# %u is 1=mon 7=sun (unless given in ARGV) +LVL=${1:-"$(date +%u)"} +BAKDIR="/bak/$(date +%F)_$LVL" + +mkdir -p "$BAKDIR" +dump -$LVL -auf "$BAKDIR/root.dump.$LVL" / +dump -$LVL -auf "$BAKDIR/home.dump.$LVL" /home +dump -$LVL -auf "$BAKDIR/var.dump.$LVL" /var -- libgit2 1.1.1