Improve docs. master
authorBernie Innocenti <bernie@codewiz.org>
Mon, 9 Aug 2021 23:27:57 +0000 (01:27 +0200)
committerBernie Innocenti <bernie@codewiz.org>
Mon, 9 Aug 2021 23:27:57 +0000 (01:27 +0200)
INSTALL [deleted file]
README.md [new file with mode: 0644]
wizbackup

diff --git a/INSTALL b/INSTALL
deleted file mode 100644 (file)
index 33e031f..0000000
--- a/INSTALL
+++ /dev/null
@@ -1,39 +0,0 @@
-== List the machines to backup ==
-
-mkdir -p /backup/HOSTS
-cat >/backup/HOSTS/example <<__EOF__
-host1.example.com
-host2.example.com
-__EOF__
-
-
-== Optionally, exclude files from backups ==
-
-mkdir -p /backup/EXCLUDE
-cat >/backup/EXCLUDE/ALWAYS <<__EOF__
-/dev/
-/mnt/
-/proc/
-/sys/
-/selinux/
-__EOF__
-
-cat >/backup/EXCLUDE/host1.example.com <<__EOF__
-/var/cache
-__EOF__
-
-
-== Install wizbackup cronjob ==
-
-cat >/etc/cron.daily/wizbackup <<__EOF__
-#!/bin/bash
-wizbackup-driver /backup/HOSTS/example /backup
-__EOF__
-
-
-== Create an ssh keypair for the hosts ==
-
-mkdir -p /etc/wizbackup
-ssh-keygen -N '' -c "wizbackup@example.com" -f /etc/wizbackup/ssh_id
-ssh-copy-id -f /etc/wizbackup/ssh_id.pub root@host1.example.com
-ssh-copy-id -f /etc/wizbackup/ssh_id.pub root@host2.example.com
diff --git a/README.md b/README.md
new file mode 100644 (file)
index 0000000..1f0dda4
--- /dev/null
+++ b/README.md
@@ -0,0 +1,65 @@
+Wizbackup is a minimalistic backup system based on rsync and hardlinked
+snapshots.
+
+Its main feature is that each backup snapshot is a plain filesystem tree, identical to the
+original. Theere's no need for a tool to restore and manage backups.
+
+There are a few downsides to this simple structure:
+ - Backups are uncompressed (unless the underlying filesystem supports transparent complression)
+ - Large files which change every day, such as logs and databases, are duplicated in each snapshot,
+   wasting space. Reflinks (aka COW-links) would solve this.
+
+
+Setup
+=====
+
+List the hosts to be backed up:
+
+```
+mkdir -p /backup/HOSTS
+cat >/backup/HOSTS/example <<__EOF__
+host1.example.com
+host2.example.com
+__EOF__
+```
+
+Optionally, specify paths to be excluded from backups:
+
+```
+mkdir -p /backup/EXCLUDE
+cat >/backup/EXCLUDE/ALWAYS <<__EOF__
+/dev/
+/mnt/
+/proc/
+/sys/
+/selinux/
+__EOF__
+```
+
+You can also specify host-specific excludes:
+
+```
+cat >/backup/EXCLUDE/host1.example.com <<__EOF__
+/var/cache
+__EOF__
+```
+
+Install the wizbackup cronjob:
+
+```
+cat >/etc/cron.daily/wizbackup <<__EOF__
+#!/bin/bash
+wizbackup-driver /backup/HOSTS/example /backup
+__EOF__
+```
+
+Create an ssh keypair for each host:
+
+```
+mkdir -p /etc/wizbackup
+ssh-keygen -N '' -c "wizbackup@example.com" -f /etc/wizbackup/ssh_id
+ssh-copy-id -f /etc/wizbackup/ssh_id.pub root@host1.example.com
+ssh-copy-id -f /etc/wizbackup/ssh_id.pub root@host2.example.com
+```
+
+That's it!
index fffd3b9f11f08d1440bdbb69bfe3f60221f349e0..746cfba7022435e3c1924188fa2c09ed329c0ce0 100755 (executable)
--- a/wizbackup
+++ b/wizbackup
@@ -116,7 +116,7 @@ do_init() {
 do_prune() {
        local num_snapshots="$1"
        local suffix="$2"
-       local oldest="$(ls -d [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$suffix | head -n -$num_snapshots)"
+       local oldest="$(ls 2>/dev/null -d [0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$suffix | head -n -$num_snapshots)"
        for old in $oldest; do
                echo "$(date): Removing oldest snapshot(s): $old..."
                rm -rf "$old" || exit 669
@@ -173,8 +173,7 @@ do_test() {
 # make sure to be root
 if (( `id -u` != 0 )); then { echo "Sorry, must be root.  Exiting..."; exit; } fi
 
-echo "$(date): BEGIN backup: $0 $@"
-echo "$(date): $0 $SRC $DEST $@"
+echo "$(date): BEGIN backup: $0 $SRC $DEST $@"
 do_init
 do_prune 6 ""
 do_prune 4 "-weekly"