--- /dev/null
+etc-obnam.debhelper.log
+etc-obnam.postrm.debhelper
+etc-obnam.substvars
+etc-obnam/
+files
--- /dev/null
+#!/bin/sh
+
+set -e
+PACKAGE=etc-obnam
+CONFIGFILE=/etc/default/$PACKAGE
+
+. /usr/share/debconf/confmodule
+
+# Load config file, if it exists.
+if [ -e $CONFIGFILE ]; then
+ . $CONFIGFILE || true
+
+ # Store values from config file into
+ # debconf db.
+ db_set $PACKAGE/host_name $HOST_NAME
+ db_set $PACKAGE/host_mac $HOST_MAC
+ db_set $PACKAGE/source $SOURCE
+fi
+
+# Ask questions.
+db_input high $PACKAGE/repository || true
+db_input high $PACKAGE/host_name || true
+db_input high $PACKAGE/host_mac || true
+db_input high $PACKAGE/source || true
+db_input low $PACKAGE/scheduled_time || true
+db_input low $PACKAGE/exclude || true
+db_go
Package: etc-obnam
Architecture: all
Depends: ${misc:Depends}
+Recommends: obnam
Description: <insert up to 60 chars description>
<insert long description, indented with spaces>
Andrew Ruthven <andrew@etc.gen.nz> on Wed, 18 Apr 2012 21:46:19 +1200
-It was downloaded from:
-
- <url://example.com>
-
-Upstream Author(s):
-
- <put author's name and email here>
- <likewise for another author>
-
Copyright:
- <Copyright (C) YYYY Firstname Lastname>
- <likewise for another author>
+ Copyright (C) 2012 Andrew Ruthven
License:
Copyright (C) 2012 Andrew Ruthven <andrew@etc.gen.nz>
-# Please chose a license for your packaging work. If the program you package
-# uses a mainstream license, using the same license is the safest choice.
-# Please avoid to pick license terms that are more restrictive than the
-# packaged work, as it may make Debian's contributions unacceptable upstream.
-# If you just want it to be GPL version 3, leave the following line in.
-
and is licensed under the GPL version 3, see above.
-
-# Please also look if there are files or directories which have a
-# different copyright/license attached and list them here.
+++ /dev/null
-#
-# Regular cron jobs for the etc-obnam package
-#
-0 4 * * * root [ -x /usr/bin/etc-obnam_maintenance ] && /usr/bin/etc-obnam_maintenance
--- /dev/null
+obnam.list /etc/apt/sources.list.d/
+run-backup /usr/lib/etc-obnam/
--- /dev/null
+/var/log/obnam.log
+{
+ weekly
+ missingok
+ rotate 4
+ compress
+ delaycompress
+ notifempty
+ create 640 root adm
+}
+++ /dev/null
-.\" Hey, EMACS: -*- nroff -*-
-.\" First parameter, NAME, should be all caps
-.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
-.\" other parameters are allowed: see man(7), man(1)
-.TH ETC-OBNAM SECTION "April 18, 2012"
-.\" Please adjust this date whenever revising the manpage.
-.\"
-.\" Some roff macros, for reference:
-.\" .nh disable hyphenation
-.\" .hy enable hyphenation
-.\" .ad l left justify
-.\" .ad b justify to both left and right margins
-.\" .nf disable filling
-.\" .fi enable filling
-.\" .br insert line break
-.\" .sp <n> insert n+1 empty lines
-.\" for manpage-specific macros, see man(7)
-.SH NAME
-etc-obnam \- program to do something
-.SH SYNOPSIS
-.B etc-obnam
-.RI [ options ] " files" ...
-.br
-.B bar
-.RI [ options ] " files" ...
-.SH DESCRIPTION
-This manual page documents briefly the
-.B etc-obnam
-and
-.B bar
-commands.
-.PP
-.\" TeX users may be more comfortable with the \fB<whatever>\fP and
-.\" \fI<whatever>\fP escape sequences to invode bold face and italics,
-.\" respectively.
-\fBetc-obnam\fP is a program that...
-.SH OPTIONS
-These programs follow the usual GNU command line syntax, with long
-options starting with two dashes (`-').
-A summary of options is included below.
-For a complete description, see the Info files.
-.TP
-.B \-h, \-\-help
-Show summary of options.
-.TP
-.B \-v, \-\-version
-Show version of program.
-.SH SEE ALSO
-.BR bar (1),
-.BR baz (1).
-.br
-The programs are documented fully by
-.IR "The Rise and Fall of a Fooish Bar" ,
-available via the Info system.
-.SH AUTHOR
-etc-obnam was written by <upstream author>.
-.PP
-This manual page was written by Andrew Ruthven <andrew@etc.gen.nz>,
-for the Debian project (and may be used by others).
set -e
-# summary of how this script can be called:
-# * <postinst> `configure' <most-recently-configured-version>
-# * <old-postinst> `abort-upgrade' <new version>
-# * <conflictor's-postinst> `abort-remove' `in-favour' <package>
-# <new-version>
-# * <postinst> `abort-remove'
-# * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
-# <failed-install-package> <version> `removing'
-# <conflicting-package> <version>
-# for details, see http://www.debian.org/doc/debian-policy/ or
-# the debian-policy package
+[ -n "${DEBUG}" ] && set -o xtrace
+PACKAGE=etc-obnam
+[ -n "${DEBUG}" ] && echo "PostInst Parameters: $@" 1>&2
+if [ -e /usr/share/debconf/confmodule ]; then
+ . /usr/share/debconf/confmodule
+ db_version 2.0
+fi
+
+generate_crontab() {
+ echo "# Crontab to run the obnam backup on a regular schedule"
+ echo "#"
+ echo "# * * * AUTOMATICALLY MAINTAINED - DO NOT EDIT * * *"
+ echo "#"
+ echo "# To modify the schedule for this job you should:"
+ echo "# dpkg-reconfigure -plow $PACKAGE"
+ echo "#"
+ echo ""
+ echo "$SCHEDULED_TIME root /usr/lib/$PACKAGE/run-backup"
+}
+
+generate_debian_config() {
+ echo "# Shell fragment to configure the $PACKAGE package"
+ echo "#"
+ echo "# You can run 'dpkg-reconfigure $PACKAGE' to modify the values in this"
+ echo "# file if you want. You can also change the values here and changes"
+ echo "# will be preserved. But other changes will not be preserved."
+ echo ""
+ echo "# Which host do we backup to?"
+ echo "HOST_NAME='$HOST_NAME'"
+ echo ""
+ echo "# What is the MAC address of the host we backup to?"
+ echo "# (Used to determine if we're on the right network, useful for generic names."
+ echo "# If this is unset, then just being able to ping the above host is sufficient.)"
+ echo "HOST_MAC='$HOST_MAC'"
+ echo ""
+ echo "# Which directories do we backup to?"
+ echo "SOURCE='$SOURCE'"
+}
+
+generate_ssh_key() {
+ ssh-keygen -q -t rsa -C "obnam@$(hostname) - $(date +%F)" -N "" -f /etc/obnam/id_rsa
+}
+
+generate_obnam_config() {
+ echo "# Configuration file for obnam."
+ echo "#"
+ echo "# This file is generated automatically. You can override these settings by"
+ echo "# creating a file which is sorted alphabetically after this one and inserting"
+ echo "# the updated settings in that file."
+ echo "#"
+ echo "[config]"
+ echo "log = /var/log/obnam.log"
+ echo "ssh-key = /etc/obnam/id_rsa"
+ echo "log-level = info"
+ echo "#"
+ echo "# To reconfigure the following settings run:"
+ echo "# dpkg-reconfigure $PACKAGE"
+ echo "repository = $REPOSITORY"
+ echo "exclude = $EXCLUDE"
+}
case "$1" in
- configure)
+ configure|reconfigure)
+ DEBIANCONFIG="/etc/default/$PACKAGE"
+ OBNAMCONFIG="/etc/obnam/${PACKAGE}.conf"
+ CRONTAB="/etc/cron.d/${PACKAGE}"
+
+ # Load current settings, most of which will be overwritten.
+ [ -f $DEBIANCONFIG ] && . $DEBIANCONFIG
+
+ db_get ${PACKAGE}/repository
+ REPOSITORY="${RET}"
+
+ db_get ${PACKAGE}/scheduled_time
+ SCHEDULED_TIME="${RET}"
+
+ db_get ${PACKAGE}/host_name
+ HOST_NAME="${RET}"
+
+ db_get ${PACKAGE}/host_mac || true
+ HOST_MAC="${RET}"
+
+ db_get ${PACKAGE}/source
+ SOURCE="${RET}"
+
+ db_get ${PACKAGE}/exclude || true
+ EXCLUDE="${RET}"
+
+ generate_crontab > $CRONTAB
+ generate_debian_config > $DEBIANCONFIG
+ generate_obnam_config > $OBNAMCONFIG
+
+ if [ ! -f /etc/obnam/id_rsa ]; then
+ generate_ssh_key
+
+ echo New ssh key generated for this host, please add it to the backup host.
+ fi
;;
abort-upgrade|abort-remove|abort-deconfigure)
--- /dev/null
+Template: etc-obnam/repository
+Type: string
+Default: sftp://backups@backup/private/obnam/backups/
+Description: URL for where to backup to, including the destination path.
+ An obnam supported URL for where to backup to.
+
+Template: etc-obnam/host_name
+Type: string
+Default: backup
+Description: The server to backup to
+ The server that we're to submit our backups to. Can be a hostname or an IP
+ address.
+
+Template: etc-obnam/host_mac
+Type: string
+Default: 00:0d:88:6b:b2:68
+Description: MAC address of the server we're backing up to.
+ The MAC address that we're submitting our backups to. Used to determine
+ if the configured hostname is accessible on the local network.
+
+Template: etc-obnam/scheduled_time
+Type: string
+Default: 10 * * * *
+Description: Adjust the cron schedule for running the backup.
+
+Template: etc-obnam/source
+Type: string
+Default: /home /etc
+Description: Directories to be included in the backup.
+ A space separated list of the directories to be backed up.
+
+Template: etc-obnam/exclude
+Type: string
+Default: \.xchat2, .*/\.cache/.*, \.thumbnails/.*, \.mozilla/firefox/.*\.default/Cache, \.local/share/Trash, /home/andrew/data/reference, /home/.*/scratch, .xbmc/temp, /home/.*/Network, .*/[Cc]ache/.*, \.evolution/mail/imap
+Description: List of regexes to be excluded from the backup.
+ A list of regexes to be excluded from the backup.
--- /dev/null
+deb http://code.liw.fi/debian squeeze main
--- /dev/null
+#!/bin/bash
+
+. /etc/default/etc-obnam
+
+CLIENT=$(hostname)
+SOURCE=${SOURCE:-/home /etc}
+
+function check_host() {
+ local type=$1
+ if [ "x$type" != "xA" -a "x$type" != "xAAAA" ]
+ then
+ echo Sorry, unknown type to check for.
+ exit 1
+ fi
+
+ # If no host is defined to check for, assume we should just run.
+ if [ "x$HOST_NAME" = "x" ]
+ then
+ return 0
+ fi
+
+ local ip=$(host -t $type $HOST_NAME | grep address | awk '{ print $NF }' | head -1)
+ if [ "x$ip" = "x" ]
+ then
+ return 1
+ fi
+
+ local cmd=ping
+ if [ $type = "AAAA" ]
+ then
+ cmd=ping6
+ fi
+
+ if ! $cmd -n -c3 $HOST_NAME &> /dev/null
+ then
+ return 1
+ fi
+
+ local mac=$(ip neigh | egrep "^$ip " | grep REACHABLE | awk '{ print $5 }' )
+ if [ $(echo $mac | wc -l ) -ne 1 ]
+ then
+ return 1
+ fi
+
+ if [ "x$HOST_MAC" != "x" -a "x$mac" != "x$HOST_MAC" ]
+ then
+ return 1
+ fi
+
+ return 0
+}
+
+if ( check_host 'AAAA' -o check_host 'A' )
+then
+ obnam --quiet --client-name=$CLIENT backup $SOURCE
+ exit 0
+else
+ echo huh, where is it?
+ exit 1
+fi