diff options
| author | Mitchell Riedstra <mitch@riedstra.dev> | 2025-12-31 17:39:36 -0500 |
|---|---|---|
| committer | Mitchell Riedstra <mitch@riedstra.dev> | 2025-12-31 17:39:36 -0500 |
| commit | 99957c2e49121b616c61e483bf6ebc2271789a50 (patch) | |
| tree | 8ac8d97c400b0df61f4362868e1ae580509c7068 /openbsd.sh | |
| download | svr-backups-master.tar.gz svr-backups-master.tar.xz | |
Diffstat (limited to 'openbsd.sh')
| -rwxr-xr-x | openbsd.sh | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/openbsd.sh b/openbsd.sh new file mode 100755 index 0000000..a876f14 --- /dev/null +++ b/openbsd.sh @@ -0,0 +1,34 @@ +#!/bin/sh +# OpenBSD backup script. Symlink into <svr>/backup.sh for use. +# Make sure you update /etc/fstab appropriately before rebooting after +# restore +# To restore packages: pkg_add -l /root/packages.lst +IFS=' +' +_paths='/root +/etc +/home +/var/redis +/var/cron +/var/mail +/var/nsd +/var/service +/var/sshkeys +/var/unbound +/var/www/htdocs +/var/rspamd +/var/spool/smtpd' + + +list="$(mktemp)" +ref="$(mktemp)" +trap 'rm "$list" "$ref"' EXIT INT +touch -d $(date -r $(($(date +%s) - 86400)) +%Y-%m-%dT%H:%M:%S) "$ref" +pkg_info -mz > /root/packages.lst +if [ "$1" = daily ] ; then + find $_paths -newer "$ref" -type f > "$list" +else + find $_paths -type f > "$list" +fi +tar -I "$list" -cf - \ + | zstd -3c |
