From: Andrew Ruthven Date: Wed, 11 Oct 2017 11:19:12 +0000 (+1300) Subject: Switch to bup X-Git-Tag: v0.10.2~1 X-Git-Url: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46e428f18029999e9df1358489a5a2b17326db5f;p=etc-obnam.git Switch to bup --- diff --git a/debian/.gitignore b/debian/.gitignore index e4f2dba..dfbccd3 100644 --- a/debian/.gitignore +++ b/debian/.gitignore @@ -1,5 +1,7 @@ -etc-obnam.debhelper.log -etc-obnam.postrm.debhelper -etc-obnam.substvars -etc-obnam/ +etc-bup.debhelper.log +etc-bup.postrm.debhelper +etc-bup.substvars +etc-bup/ files +debhelper-build-stamp + diff --git a/debian/README.Debian b/debian/README.Debian index bfe6b90..8e214de 100644 --- a/debian/README.Debian +++ b/debian/README.Debian @@ -1,4 +1,4 @@ -etc-obnam for Debian +etc-bup for Debian -------------------- diff --git a/debian/changelog b/debian/changelog index 8312b56..0373fd8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +etc-bup (0.10.1) unstable; urgency=medium + + * Minor fixes + + -- Andrew Ruthven Thu, 12 Oct 2017 00:15:03 +1300 + +etc-bup (0.10) unstable; urgency=medium + + * Rename from etc-obnam as now I'm using bup for my backups. + + -- Andrew Ruthven Sun, 08 Oct 2017 10:27:13 +1300 + etc-obnam (0.9) unstable; urgency=low * Sigh. We need to use egrep to use a regex in grep. diff --git a/debian/compat b/debian/compat index 7f8f011..f599e28 100644 --- a/debian/compat +++ b/debian/compat @@ -1 +1 @@ -7 +10 diff --git a/debian/conffile b/debian/conffile index f723325..af1b20f 100644 --- a/debian/conffile +++ b/debian/conffile @@ -1,3 +1,2 @@ -/etc/obnam/id_rsa -/etc/obnam/id_rsa.pub -/etc/obnam/etc-obnam.conf +/etc/etc-bup/id_rsa +/etc/etc-bup/id_rsa.pub diff --git a/debian/config b/debian/config index 392c500..7c1eb1d 100644 --- a/debian/config +++ b/debian/config @@ -1,7 +1,7 @@ #!/bin/sh set -e -PACKAGE=etc-obnam +PACKAGE=etc-bup CONFIGFILE=/etc/default/$PACKAGE . /usr/share/debconf/confmodule diff --git a/debian/control b/debian/control index 191cb44..f1160fc 100644 --- a/debian/control +++ b/debian/control @@ -1,4 +1,4 @@ -Source: etc-obnam +Source: etc-bup Section: optional Priority: extra Maintainer: Andrew Ruthven @@ -7,9 +7,9 @@ Standards-Version: 3.8.4 Vcs-Git: git://git.etc.gen.nz/etc-obnam.git Vcs-Browser: http://git.etc.gen.nz/cgi-bin/gitweb.cgi?p=etc-obnam.git;a=summary -Package: etc-obnam +Package: etc-bup Architecture: all Depends: ${misc:Depends}, debconf-utils, bind9-host, procmail -Recommends: obnam, molly-guard -Description: Wrapper around obnam for backing up laptops and PCs - Runs obnam on a schedule, but only if we're on the right network. +Recommends: bup, molly-guard +Description: Wrapper around bup for backing up laptops and PCs + Runs bup on a schedule, but only if we're on the right network. diff --git a/debian/dirs b/debian/dirs index 10262aa..1db911d 100644 --- a/debian/dirs +++ b/debian/dirs @@ -1,2 +1,2 @@ -/var/lib/etc-obnam -/etc/obnam +/var/lib/etc-bup +/etc/etc-bup diff --git a/debian/install b/debian/install index ed80e9a..f6904bd 100644 --- a/debian/install +++ b/debian/install @@ -1,3 +1,2 @@ -obnam.list /etc/apt/sources.list.d/ -run-backup /usr/lib/etc-obnam/ -molly-guard/45-obnam /etc/molly-guard/run.d +run-backup /usr/lib/etc-bup/ +molly-guard/45-bup /etc/molly-guard/run.d diff --git a/debian/logrotate b/debian/logrotate index 9e2f58e..7ba360f 100644 --- a/debian/logrotate +++ b/debian/logrotate @@ -1,4 +1,4 @@ -/var/log/obnam.log +/var/log/bup.log { weekly missingok diff --git a/debian/postinst b/debian/postinst index 7761257..83bb221 100644 --- a/debian/postinst +++ b/debian/postinst @@ -1,12 +1,12 @@ #!/bin/sh -# postinst script for etc-obnam +# postinst script for etc-bup # # see: dh_installdeb(1) set -e [ -n "${DEBUG}" ] && set -o xtrace -PACKAGE=etc-obnam +PACKAGE=etc-bup [ -n "${DEBUG}" ] && echo "PostInst Parameters: $@" 1>&2 if [ -e /usr/share/debconf/confmodule ]; then @@ -15,7 +15,7 @@ if [ -e /usr/share/debconf/confmodule ]; then fi generate_crontab() { - echo "# Crontab to run the obnam backup on a regular schedule" + echo "# Crontab to run the bup backup on a regular schedule" echo "#" echo "# * * * AUTOMATICALLY MAINTAINED - DO NOT EDIT * * *" echo "#" @@ -41,38 +41,32 @@ generate_debian_config() { echo "# If this is unset, then just being able to ping the above host is sufficient.)" echo "HOST_MAC='$HOST_MAC'" echo "" + echo "# Repository we're backing up to" + echo "REPOSITORY='$REPOSITORY'" + 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 + ssh-keygen -q -t rsa -C "bup@$(hostname) - $(date +%F)" -N "" -f /etc/bup/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 "lock-timeout = 600" - echo "#" - echo "# To reconfigure the following settings run:" - echo "# dpkg-reconfigure $PACKAGE" - echo "repository = $REPOSITORY" - echo "exclude = $EXCLUDE" +generate_ssh_config() { + echo "Host $HOST_NAME" + echo " User $BUP_USER" + echo " IdentityFile /etc/${PACKAGE}/id_rsa" } case "$1" in configure|reconfigure) DEBIANCONFIG="/etc/default/$PACKAGE" - OBNAMCONFIG="/etc/obnam/${PACKAGE}.conf" CRONTAB="/etc/cron.d/${PACKAGE}" + SSHCONFIG="/etc/${PACKAGE}/ssh_config" + + # To allow migration from etc-obnam, if no etc-bup config file eixsts, + # but etc-obnam config exists, we load that. + [ ! -f $DEBIANCONFIG -a -f /etc/default/etc-obnam ] && . /etc/default/etc-obnam # Load current settings, most of which will be overwritten. [ -f $DEBIANCONFIG ] && . $DEBIANCONFIG @@ -89,6 +83,9 @@ case "$1" in db_get ${PACKAGE}/host_mac || true HOST_MAC="${RET}" + db_get ${PACKAGE}/user || true + BUP_USER="${RET}" + db_get ${PACKAGE}/source SOURCE="${RET}" @@ -97,12 +94,22 @@ case "$1" in generate_crontab > $CRONTAB generate_debian_config > $DEBIANCONFIG - generate_obnam_config > $OBNAMCONFIG + generate_ssh_config > $SSHCONFIG + echo $EXCLUDE | perl -nlpe "s/, /\n/g" > /etc/$PACKAGE/exclude.list + + if ! grep -q $SSHCONFIG /root/.ssh/config; then + [ -d /root/.ssh/config ] || mkdir -p /root/.ssh + echo -e "\n\nInclude $SSHCONFIG" >> /root/.ssh/config + fi - if [ ! -f /etc/obnam/id_rsa ]; then - generate_ssh_key + if [ ! -f /etc/$PACKAGEid_rsa ]; then + if [ -f /etc/obnam/id_rsa ]; then + cp /etc/obnam/id_rsa* /etc/$PACKAGE + else + generate_ssh_key - echo New ssh key generated for this host, please add it to the backup host. + echo New ssh key generated for this host, please add it to the backup host. + fi fi ;; diff --git a/debian/templates b/debian/templates index 885d937..fe5df25 100644 --- a/debian/templates +++ b/debian/templates @@ -1,35 +1,42 @@ -Template: etc-obnam/repository +Template: etc-bup/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. +Default: /private/bup/backups/ +Description: Path of where we should backup + A bup supported path for where to backup to. If using a remote server, + exclude the server name. -Template: etc-obnam/host_name +Template: etc-bup/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 +Template: etc-bup/host_mac Type: string -Default: 00:1a:4d:9e:2d:11 +Default: 70:71:bc:a8:1f:a1 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 +Template: etc-bup/user +Type: string +Default: backups +Description: Name of the user on the remote server to connect to. + Who do we connect as? + +Template: etc-bup/scheduled_time Type: string Default: 10 * * * * Description: Adjust the cron schedule for running the backup. -Template: etc-obnam/source +Template: etc-bup/source Type: string Default: /home /etc /var/spool/cron/crontabs Description: Directories to be included in the backup. A space separated list of the directories to be backed up. -Template: etc-obnam/exclude +Template: etc-bup/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. diff --git a/molly-guard/45-obnam b/molly-guard/45-bup similarity index 63% rename from molly-guard/45-obnam rename to molly-guard/45-bup index 884397a..31b4ae1 100755 --- a/molly-guard/45-obnam +++ b/molly-guard/45-bup @@ -2,9 +2,9 @@ ME=molly-guard -COUNT=$(ps ax | grep obnam | egrep -v "(grep|$0)" | wc -l) +COUNT=$(ps ax | grep bup | egrep -v "(grep|$0)" | wc -l) if [ $COUNT -eq 0 ]; then - echo "I: I can't find any running obnam backups, skipping check" >&2 + echo "I: I can't find any running bup backups, skipping check" >&2 exit 0; fi @@ -18,7 +18,7 @@ sigh() trap 'echo;sigh' 1 2 3 9 10 12 15 -echo -n "Obnam is running a backup. Type YES to $MOLLYGUARD_CMD: " +echo -n "bup is running a backup. Type YES to $MOLLYGUARD_CMD: " read CONFIRM || : [ $(echo "x$CONFIRM" | tr 'A-Z' 'a-z') = "xyes" ] || sigh diff --git a/obnam.list b/obnam.list deleted file mode 100644 index 15c8a15..0000000 --- a/obnam.list +++ /dev/null @@ -1 +0,0 @@ -deb http://code.liw.fi/debian squeeze main diff --git a/run-backup b/run-backup index 2d79c8a..53a51ab 100755 --- a/run-backup +++ b/run-backup @@ -1,6 +1,6 @@ #!/bin/bash -# Conditionally run obnam. +# Conditionally run bup. # # If $HOST_NAME is defined, check that we can ping it. # If $HOST_MAC is defined, check that the arp/neighbour table has a matching @@ -8,11 +8,11 @@ # If those conditions are meet, then backup $SOURCE, but first grab some # debconf data so we can reconstruct the packages installed if we need to. -. /etc/default/etc-obnam +. /etc/default/etc-bup CLIENT=$(hostname) SOURCE=${SOURCE:-/home /etc} -WORKDIR=/var/lib/etc-obnam +WORKDIR=/var/lib/etc-bup # Check that the host is local, support both IPv4 and IPv6. check_host() { @@ -37,7 +37,7 @@ check_host() { fi # ping or ping6? - local cmd=ping + local cmd=ping4 if [ $type = "AAAA" ] then cmd=ping6 @@ -91,17 +91,23 @@ if check_host 'AAAA' || check_host 'A' then capture_debconf_info - if ! lockfile -r20 /var/lock/etc-obnam + if ! lockfile -r20 /var/lock/etc-bup then echo Failed to obtain local lock exit fi + # If this is the first time we're running, init ourselves. + if [ ! -d /root/.bup ]; then + bup init -r $HOST_NAME:$REPOSITORY + fi + # We try to impact on the user as much as possible, so nice # ourselves completely. - ionice -c idle nice obnam --quiet --client-name=$CLIENT backup $WORKDIR $SOURCE + ionice -c idle nice bup index --exclude-rx-from /etc/etc-bup/exclude.list $SOURCE $WORKDIR + ionice -c idle nice bup save -r $HOST_NAME:$REPOSITORY -n $CLIENT $SOURCE $WORKDIR - rm /var/lock/etc-obnam + rm /var/lock/etc-bup exit 0 else echo huh, where is it?