aboutsummaryrefslogtreecommitdiff
path: root/handlers
diff options
context:
space:
mode:
Diffstat (limited to 'handlers')
-rw-r--r--handlers/Makefile.am92
-rw-r--r--handlers/dup.helper.in514
-rw-r--r--handlers/dup.in279
-rw-r--r--handlers/ldap.helper.in90
-rw-r--r--handlers/ldap.in111
-rw-r--r--handlers/maildir.in370
-rw-r--r--handlers/makecd.helper.in97
-rw-r--r--handlers/makecd.in88
-rw-r--r--handlers/mysql.helper.in217
-rw-r--r--handlers/mysql.in320
-rw-r--r--handlers/pgsql.helper.in107
-rw-r--r--handlers/pgsql.in133
-rw-r--r--handlers/rdiff.helper.in407
-rw-r--r--handlers/rdiff.in257
-rw-r--r--handlers/rsync.in350
-rw-r--r--handlers/sh.in7
-rw-r--r--handlers/svn.in77
-rw-r--r--handlers/sys.helper.in53
-rwxr-xr-xhandlers/sys.in682
-rw-r--r--handlers/tar.helper.in94
-rw-r--r--handlers/tar.in79
-rw-r--r--handlers/trac.in52
-rw-r--r--handlers/wget220
23 files changed, 0 insertions, 4696 deletions
diff --git a/handlers/Makefile.am b/handlers/Makefile.am
deleted file mode 100644
index eaf4b9e..0000000
--- a/handlers/Makefile.am
+++ /dev/null
@@ -1,92 +0,0 @@
-
-HANDLERS = dup dup.helper ldap ldap.helper maildir makecd \
- makecd.helper mysql mysql.helper pgsql pgsql.helper rdiff \
- rdiff.helper rsync sh svn sys sys.helper trac
-
-CLEANFILES = $(HANDLERS)
-
-EXTRA_DIST = Makefile.am $(HANDLERS)
-
-edit = sed \
- -e "s,@BASH\@,$(BASH),g" \
- -e "s,@AWK\@,$(AWK),g" \
- -e "s,@SED\@,$(SED),g"
-
-dist_pkgdata_DATA = $(HANDLERS)
-
-dup: $(srcdir)/dup.in
- rm -f dup
- $(edit) $(srcdir)/dup.in > dup
-
-dup.helper: $(srcdir)/dup.helper.in
- rm -f dup.helper
- $(edit) $(srcdir)/dup.helper.in > dup.helper
-
-ldap: $(srcdir)/ldap.in
- rm -f ldap
- $(edit) $(srcdir)/ldap.in > ldap
-
-ldap.helper: $(srcdir)/ldap.helper.in
- rm -f ldap.helper
- $(edit) $(srcdir)/ldap.helper.in > ldap.helper
-
-maildir: $(srcdir)/maildir.in
- rm -f maildir
- $(edit) $(srcdir)/maildir.in > maildir
-
-makecd: $(srcdir)/makecd.in
- rm -f makecd
- $(edit) $(srcdir)/makecd.in > makecd
-
-makecd.helper: $(srcdir)/makecd.helper.in
- rm -f makecd.helper
- $(edit) $(srcdir)/makecd.helper.in > makecd.helper
-
-mysql: $(srcdir)/mysql.in
- rm -f mysql
- $(edit) $(srcdir)/mysql.in > mysql
-
-mysql.helper: $(srcdir)/mysql.helper.in
- rm -f mysql.helper
- $(edit) $(srcdir)/mysql.helper.in > mysql.helper
-
-pgsql: $(srcdir)/pgsql.in
- rm -f pgsql
- $(edit) $(srcdir)/pgsql.in > pgsql
-
-pgsql.helper: $(srcdir)/pgsql.helper.in
- rm -f pgsql.helper
- $(edit) $(srcdir)/pgsql.helper.in > pgsql.helper
-
-rdiff: $(srcdir)/rdiff.in
- rm -f rdiff
- $(edit) $(srcdir)/rdiff.in > rdiff
-
-rdiff.helper: $(srcdir)/rdiff.helper.in
- rm -f rdiff.helper
- $(edit) $(srcdir)/rdiff.helper.in > rdiff.helper
-
-rsync: $(srcdir)/rsync.in
- rm -f rsync
- $(edit) $(srcdir)/rsync.in > rsync
-
-sh: $(srcdir)/sh.in
- rm -f sh
- $(edit) $(srcdir)/sh.in > sh
-
-svn: $(srcdir)/svn.in
- rm -f svn
- $(edit) $(srcdir)/svn.in > svn
-
-sys: $(srcdir)/sys.in
- rm -f sys
- $(edit) $(srcdir)/sys.in > sys
-
-sys.helper: $(srcdir)/sys.helper.in
- rm -f sys.helper
- $(edit) $(srcdir)/sys.helper.in > sys.helper
-
-trac: $(srcdir)/trac.in
- rm -f trac
- $(edit) $(srcdir)/trac.in > trac
-
diff --git a/handlers/dup.helper.in b/handlers/dup.helper.in
deleted file mode 100644
index c1fbdd5..0000000
--- a/handlers/dup.helper.in
+++ /dev/null
@@ -1,514 +0,0 @@
-# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
-
-HELPERS="$HELPERS dup:incremental_encrypted_remote_filesystem_backup"
-
-### Functions
-
-do_dup_host_includes() {
- set -o noglob
- # choose the files to backup
- REPLY=
- while [ -z "$REPLY" ]; do
- formBegin "$dup_title - host system: includes"
- [ -z "$dup_includes" ] && dup_includes="$dup_default_includes"
- for i in $dup_includes; do
- formItem include "$i"
- done
- formItem include ""
- formItem include ""
- formItem include ""
- formDisplay
- [ $? = 0 ] || return 1
- dup_includes="$REPLY"
- done
- set +o noglob
-}
-
-do_dup_vserver() {
- # choose the vservers to backup (into $selected_vservers)
- choose_one_or_more_vservers "$dup_title"
- [ $? = 0 ] || return 1
-
- set -o noglob
- # choose the files to backup
- REPLY=
- while [ -z "$REPLY" ]; do
- formBegin "$dup_title - vservers: vsincludes (backup these directories from every selected vserver)"
- [ -z "$dup_vsincludes" ] && dup_vsincludes="$dup_default_includes"
- for i in $dup_vsincludes; do
- formItem include "$i"
- done
- formItem include ""
- formItem include ""
- formItem include ""
- formDisplay
- [ $? = 0 ] || return 1
- dup_vsincludes="$REPLY"
- done
- set +o noglob
-}
-
-do_dup_excludes() {
- set -o noglob
- formBegin "$dup_title: excludes"
- [ -z "$dup_excludes" ] && dup_excludes="$dup_default_excludes"
- for i in $dup_excludes; do
- formItem exclude "$i"
- done
- formItem exclude ""
- formItem exclude ""
- formItem exclude ""
- formDisplay
- [ $? = 0 ] || return 1
- dup_excludes="$REPLY"
- set +o noglob
-}
-
-do_dup_src() {
- choose_host_or_vservers_or_both "$dup_title"
- [ $? = 0 ] || return 1
- case $host_or_vservers in
- 'host')
- do_dup_host_includes
- [ $? = 0 ] || return 1
- ;;
- 'vservers')
- do_dup_vserver
- [ $? = 0 ] || return 1
- ;;
- 'both')
- do_dup_host_includes
- [ $? = 0 ] || return 1
- do_dup_vserver
- [ $? = 0 ] || return 1
- ;;
- *)
- return 1
- ;;
- esac
- do_dup_excludes
- [ $? = 0 ] || return 1
-
- _src_done="(DONE)"
- setDefault dest
-}
-
-do_dup_dest() {
-
- local replyconverted
- local thereply
-
- set -o noglob
- REPLY=
- while [ -z "$REPLY" -o -z "$dup_destdir" -o -z "$dup_desthost" -o -z "$dup_destuser" ]; do
- formBegin "$dup_title - destination: first three items are compulsory"
- formItem "desthost" "$dup_desthost"
- formItem "destuser" "$dup_destuser"
- formItem "destdir" "$dup_destdir"
- formItem "keep" "$dup_keep"
- formItem "incremental" "$dup_incremental"
- formItem "bandwidthlimit" "$dup_bandwidth"
- formItem "sshoptions" "$dup_sshoptions"
- formDisplay
- [ $? = 0 ] || return 1
-
- IFS=$''
- replyconverted=`echo $REPLY | tr '\n' :`
- IFS=$':'
- thereply=($replyconverted)
- IFS=$' \t\n'
-
- dup_desthost=${thereply[0]}
- dup_destuser=${thereply[1]}
- dup_destdir=${thereply[2]}
- dup_keep=${thereply[3]}
- dup_incremental=${thereply[4]}
- dup_bandwidth=${thereply[5]}
- dup_sshoptions=${thereply[6]}
-
- done
- set +o noglob
-
- _dest_done="(DONE)"
- setDefault gpg
-}
-
-do_dup_gpg_encryptkey() {
- REPLY=
- while [ -z "$REPLY" -o -z "$dup_gpg_encryptkey" ]; do
- inputBox "$dup_title - GnuPG" "Enter ID of the public GnuPG key to be used to encrypt the backups:" "$dup_gpg_encryptkey"
- [ $? = 0 ] || return 1
- dup_gpg_encryptkey="$REPLY"
- done
-}
-
-do_dup_gpg_sign() {
- # sign ?
- booleanBox "$dup_title - GnuPG" "Sign the backups?" "$dup_gpg_sign"
- if [ $? = 0 ]; then
- dup_gpg_sign=yes
- else
- dup_gpg_sign=no
- fi
-}
-
-do_dup_gpg_signkey() {
- # one key pair ?
- booleanBox "$dup_title - GnuPG" "Use the same GnuPG key pair for encryption and signing?" "$dup_gpg_onekeypair"
- if [ $? = 0 ]; then
- dup_gpg_onekeypair=yes
- else
- dup_gpg_onekeypair=no
- fi
-
- if [ "$dup_gpg_onekeypair" == "no" }; then
- # signkey ?
- REPLY=
- while [ -z "$REPLY" -o -z "$dup_gpg_signkey" ]; do
- inputBox "$dup_title - GnuPG" "Enter the ID of the private GnuPG key to be used to sign the backups:" "$dup_gpg_signkey"
- [ $? = 0 ] || return 1
- dup_gpg_signkey="$REPLY"
- done
- fi
-}
-
-do_dup_gpg_passphrase() {
- local question="Enter the passphrase needed to unlock the GnuPG key:"
- REPLY=
- while [ -z "$REPLY" -o -z "$dup_gpg_password" ]; do
- passwordBox "$dup_title - GnuPG" "$question"
- [ $? = 0 ] || return 1
- dup_gpg_password="$REPLY"
- done
-}
-
-do_dup_gpg() {
-
- # symmetric or public key encryption ?
- booleanBox "$dup_title - GnuPG" "Use public key encryption? Otherwise, symmetric encryption will be used, and data signing will be impossible." "$dup_gpg_asymmetric_encryption"
- if [ $? = 0 ]; then
- dup_gpg_asymmetric_encryption=yes
- else
- dup_gpg_asymmetric_encryption=no
- fi
-
- # when using public/private key pair encryption, ask for the keys to use
- if [ "$dup_gpg_asymmetric_encryption" == yes ]; then
- do_dup_gpg_encryptkey ; [ $? = 0 ] || return 1
- do_dup_gpg_sign ; [ $? = 0 ] || return 1
- if [ "$dup_gpg_sign" == yes ]; then
- do_dup_gpg_signkey ; [ $? = 0 ] || return 1
- fi
- else
- dup_gpg_sign=no
- fi
-
- # a passphrase is alway needed
- do_dup_gpg_passphrase
-
- _gpg_done="(DONE)"
- setDefault adv
- # TODO: replace the above line by the following when do_dup_conn is written
- # setDefault conn
-}
-
-# TODO: share rdiff.helper code in some lib, and use it here
-do_dup_conn() {
- _con_done="(DONE)"
- setDefault adv
-}
-
-do_dup_misc_options() {
-
- set -o noglob
- local replyconverted
- local thereply
-
- formBegin "$dup_title - misc. options"
- formItem "nicelevel" "$dup_nicelevel"
- formItem "testconnect" "$dup_testconnect"
- formItem "options" "$dup_options"
- formDisplay
- [ $? = 0 ] || return 1
-
- IFS=$''
- replyconverted=`echo $REPLY | tr '\n' :`
- IFS=$':'
- thereply=($replyconverted)
- IFS=$' \t\n'
-
- dup_nicelevel=${thereply[0]}
- dup_testconnect=${thereply[1]}
- dup_options=${thereply[2]}
-
- set +o noglob
-}
-
-# (rdiff.helper compatible interface... there could be some sode to share, hmmm.)
-do_dup_adv() {
- do_dup_misc_options
- [ $? = 0 ] || return 1
- _adv_done="(DONE)"
- setDefault finish
-}
-
-do_dup_finish() {
- get_next_filename $configdirectory/90.dup
- cat > $next_filename <<EOF
-# passed directly to duplicity
-#options = --verbosity 8
-options = $dup_options
-
-# default is 0, but set to 19 if you want to lower the priority.
-nicelevel = $dup_nicelevel
-
-# default is yes. set to no to skip the test if the remote host is alive
-testconnect = $dup_testconnect
-
-######################################################
-## gpg section
-## (how to encrypt and optionally sign the backups)
-##
-## WARNING: old (pre-0.9.4) example.dup used to give wrong information about
-## the way the following options are used. Please read the following
-## carefully.
-##
-## If the encryptkey variable is set:
-## - data is encrypted with the GnuPG public key specified by the encryptkey
-## variable
-## - if signing is enabled, data is signed with the GnuPG private
-## key specified by the signkey variable
-## - the password variable is used to unlock the GnuPG key(s) used
-## for encryption and (optionnal) signing
-##
-## If the encryptkey option is not set:
-## - data signing is not possible
-## - the password variable is used to encrypt the data with symmetric
-## encryption: no GnuPG key pair is needed
-
-[gpg]
-
-# when set to yes, encryptkey variable must be set below; if you want to use
-# two different keys for encryption and signing, you must also set the signkey
-# variable below.
-# default is no, for backwards compatibility with backupninja <= 0.5.
-sign = $dup_gpg_sign
-
-# ID of the GnuPG public key used for data encryption.
-# if not set, symmetric encryption is used, and data signing is not possible.
-encryptkey = $dup_gpg_encryptkey
-
-# ID of the GnuPG private key used for data signing.
-# if not set, encryptkey will be used.
-signkey = $dup_gpg_signkey
-
-# password
-# NB: neither quote this, nor should it include any quotes
-password = $dup_gpg_password
-
-######################################################
-## source section
-## (where the files to be backed up are coming from)
-
-[source]
-
-# A few notes about includes and excludes:
-# 1. include, exclude and vsinclude statements support globbing with '*'
-# 2. Symlinks are not dereferenced. Moreover, an include line whose path
-# contains, at any level, a symlink to a directory, will only have the
-# symlink backed-up, not the target directory's content. Yes, you have to
-# dereference yourself the symlinks, or to use 'mount --bind' instead.
-# Example: let's say /home is a symlink to /mnt/crypt/home ; the following
-# line will only backup a "/home" symlink ; neither /home/user nor
-# /home/user/Mail will be backed-up :
-# include = /home/user/Mail
-# A workaround is to 'mount --bind /mnt/crypt/home /home' ; another one is to
-# write :
-# include = /mnt/crypt/home/user/Mail
-# 3. All the excludes come after all the includes. The order is not otherwise
-# taken into account.
-
-# files to include in the backup
-EOF
-
- if [ "$host_or_vservers" == host -o "$host_or_vservers" == both ]; then
- set -o noglob
- for i in $dup_includes; do
- echo "include = $i" >> $next_filename
- done
- set +o noglob
- fi
-
- cat >> $next_filename <<EOF
-
-# If vservers = yes in /etc/backupninja.conf then the following variables can
-# be used:
-# vsnames = all | <vserver1> <vserver2> ... (default = all)
-# vsinclude = <path>
-# vsinclude = <path>
-# ...
-# Any path specified in vsinclude is added to the include list for each vserver
-# listed in vsnames (or all if vsnames = all, which is the default).
-#
-# For example, vsinclude = /home will backup the /home directory in every
-# vserver listed in vsnames. If you have 'vsnames = foo bar baz', this
-# vsinclude will add to the include list /vservers/foo/home, /vservers/bar/home
-# and /vservers/baz/home.
-# Vservers paths are derived from $VROOTDIR.
-
-EOF
-
- if [ "$host_or_vservers" == vservers -o "$host_or_vservers" == both ]; then
- set -o noglob
- echo -e "vsnames = $selected_vservers\n" >> $next_filename
- for i in $dup_vsincludes; do
- echo "vsinclude = $i" >> $next_filename
- done
- set +o noglob
- fi
-
- # excludes
- cat >> $next_filename <<EOF
-
-# files to exclude from the backup
-EOF
- set -o noglob
- for i in $dup_excludes; do
- echo "exclude = $i" >> $next_filename
- done
- set +o noglob
-
- cat >> $next_filename <<EOF
-
-######################################################
-## destination section
-## (where the files are copied to)
-
-[dest]
-
-# perform an incremental backup? (default = yes)
-# if incremental = no, perform a full backup in order to start a new backup set
-incremental = $dup_incremental
-
-# how many days of data to keep ; default is 60 days.
-# (you can also use the time format of duplicity)
-# 'keep = yes' means : do not delete old data, the remote host will take care of this
-#keep = 60
-#keep = yes
-keep = $dup_keep
-
-# full destination URL, in duplicity format; if set, desturl overrides
-# sshoptions, destdir, desthost and destuser; it also disables testconnect and
-# bandwithlimit. For details, see duplicity manpage, section "URL FORMAT".
-#desturl = file:///usr/local/backup
-#desturl = rsync://user@other.host//var/backup/bla
-
-# bandwith limit, in kbit/s ; default is 0, i.e. no limit
-#bandwidthlimit = 128
-bandwidthlimit = $dup_bandwidth
-
-# passed directly to ssh, scp (and sftp in duplicity >=0.4.2)
-# warning: sftp does not support all scp options, especially -i; as
-# a workaround, you can use "-o <SSHOPTION>"
-#sshoptions = -o IdentityFile=/root/.ssh/id_dsa_duplicity
-sshoptions = $dup_sshoptions
-
-# put the backups under this directory
-destdir = $dup_destdir
-
-# the machine which will receive the backups
-desthost = $dup_desthost
-
-# make the files owned by this user
-# note: you must be able to ssh backupuser@backhost
-# without specifying a password (if type = remote).
-destuser = $dup_destuser
-
-EOF
-
- chmod 600 $next_filename
-
-}
-
-dup_main_menu() {
-
- while true; do
- srcitem="choose files to include & exclude $_src_done"
- destitem="configure backup destination $_dest_done"
- gpgitem="configure GnuPG encryption/signing $_gpg_done"
- conitem="set up ssh keys and test remote connection $_con_done"
- advitem="edit advanced settings $_adv_done"
- # TODO: add the following to the menu when do_dup_conn is written
- # conn "$conitem" \
- menuBox "$dup_title" "choose a step:" \
- src "$srcitem" \
- dest "$destitem" \
- gpg "$gpgitem" \
- adv "$advitem" \
- finish "finish and create config file"
- [ $? = 0 ] || return 1
- result="$REPLY"
-
- case "$result" in
- "src") do_dup_src;;
- "dest") do_dup_dest;;
- "gpg") do_dup_gpg;;
- # TODO: enable the following when do_dup_conn is written
- # "conn") do_dup_conn;;
- "adv") do_dup_adv;;
- "finish")
- if [[ "$_dest_done$_gpg_done$_src_done" != "(DONE)(DONE)(DONE)" ]]; then
- # TODO: replace the previous test by the following when do_dup_conn is written
- # if [[ "$_con_done$_dest_done$_gpg_done$_src_done" != "(DONE)(DONE)(DONE)(DONE)" ]]; then
- msgBox "$dup_title" "You cannot create the configuration file until the four first steps are completed."
- else
- do_dup_finish
- break
- fi
- ;;
- esac
-
- done
-}
-
-### Main function
-
-dup_wizard() {
-
- require_packages duplicity
-
- # Global variables
- dup_title="Duplicity action wizard"
- _src_done=
- _dest_done=
- _con_done=
- _gpg_done=
- _adv_done=
- dup_includes=
- dup_excludes=
- dup_vsincludes=
- dup_incremental=yes
- dup_keep=60
- dup_bandwidth=
- dup_sshoptions=
- dup_destdir="/backups/`hostname`"
- dup_desthost=
- dup_destuser=
- dup_gpg_asymmetric_encryption="yes"
- dup_gpg_encryptkey=""
- dup_gpg_sign="yes"
- dup_gpg_onekeypair="yes"
- dup_gpg_signkey=""
- dup_gpg_password=""
- dup_nicelevel=19
- dup_testconnect=yes
- dup_options=
-
- # Global variables whose '*' shall not be expanded
- set -o noglob
- dup_default_includes="/var/spool/cron/crontabs /var/backups /etc /root /home /usr/local/*bin /var/lib/dpkg/status*"
- dup_default_excludes="/home/*/.gnupg /home/*/.gnupg /home/*/.local/share/Trash /home/*/.Trash /home/*/.thumbnails /home/*/.beagle /home/*/.aMule /home/*/gtk-gnutella-downloads"
- set +o noglob
-
- dup_main_menu
-}
diff --git a/handlers/dup.in b/handlers/dup.in
deleted file mode 100644
index 9c6a493..0000000
--- a/handlers/dup.in
+++ /dev/null
@@ -1,279 +0,0 @@
-# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
-#
-# duplicity script for backupninja
-# requires duplicity
-#
-
-getconf options
-getconf testconnect yes
-getconf nicelevel 0
-getconf tmpdir
-
-setsection gpg
-getconf password
-getconf sign no
-getconf encryptkey
-getconf signkey
-
-setsection source
-getconf include
-getconf vsnames all
-getconf vsinclude
-getconf exclude
-
-setsection dest
-getconf incremental yes
-getconf keep 60
-getconf desturl
-getconf sshoptions
-getconf bandwidthlimit 0
-getconf desthost
-getconf destdir
-getconf destuser
-destdir=${destdir%/}
-
-### SANITY CHECKS ##############################################################
-
-[ -n "$desturl" -o -n "$destdir" ] || fatal "The destination directory (destdir) must be set when desturl is not used."
-[ -n "$include" -o -n "$vsinclude" ] || fatal "No source includes specified"
-[ -n "$password" ] || fatal "The password option must be set."
-
-### VServers
-# If vservers are configured, check that the ones listed in $vsnames do exist.
-local usevserver=no
-if [ $vservers_are_available = yes ]; then
- if [ "$vsnames" = all ]; then
- vsnames="$found_vservers"
- else
- if ! vservers_exist "$vsnames" ; then
- fatal "At least one of the vservers listed in vsnames ($vsnames) does not exist."
- fi
- fi
- if [ -n "$vsinclude" ]; then
- info "Using vservers '$vsnames'"
- usevserver=yes
- fi
-else
- [ -z "$vsinclude" ] || warning 'vservers support disabled in backupninja.conf, vsincludes configuration lines will be ignored'
-fi
-
-### See if we can login on $desthost
-if [ "$testconnect" == "yes" ]; then
- if [ -n "$desturl" ]; then
- warning 'testconnect can not be used when desturl is set'
- else
- debug "ssh $sshoptions -o PasswordAuthentication=no $desthost -l $destuser 'echo -n 1'"
- if [ ! $test ]; then
- result=`ssh $sshoptions -o PasswordAuthentication=no $desthost -l $destuser 'echo -n 1'`
- if [ "$result" != "1" ]; then
- fatal "Can't connect to $desthost as $destuser."
- else
- debug "Connected to $desthost as $destuser successfully"
- fi
- fi
- fi
-fi
-
-### COMMAND-LINE MANGLING ######################################################
-
-### initialize $execstr*
-execstr_command=
-execstr_options="$options --no-print-statistics"
-execstr_source=
-if [ -n "$desturl" ]; then
- [ -z "$destuser" ] || warning 'the configured destuser is ignored since desturl is set'
- [ -z "$desthost" ] || warning 'the configured desthost is ignored since desturl is set'
- [ -z "$destdir" ] || warning 'the configured destdir is ignored since desturl is set'
- execstr_serverpart="$desturl"
-else
- execstr_serverpart="scp://$destuser@$desthost/$destdir"
-fi
-
-### duplicity version
-duplicity_version="`duplicity --version | @AWK@ '{print $2}'`"
-duplicity_major="`echo $duplicity_version | @AWK@ -F '.' '{print $1}'`"
-duplicity_minor="`echo $duplicity_version | @AWK@ -F '.' '{print $2}'`"
-duplicity_sub="`echo $duplicity_version | @AWK@ -F '.' '{print $3}'`"
-
-### ssh/scp/sftp options
-# 1. duplicity >= 0.4.2 needs --sftp-command
-# (NB: sftp does not support the -l option)
-# 2. duplicity 0.4.3 to 0.4.9 replace --ssh-command with --ssh-options, which is
-# passed to scp and sftp commands by duplicity. We don't use it: since this
-# version does not use the ssh command anymore, we keep compatibility with
-# our previous config files by passing $sshoptions to --scp-command and
-# --sftp-command ourselves
-
-scpoptions="$sshoptions"
-if [ "$bandwidthlimit" =! 0 ]; then
- [ -z "$testurl" ] || warning 'The bandwidthlimit option is not used when desturl is set.'
- scpoptions="$scpoptions -l $bandwidthlimit"
-fi
-
-# < 0.4.2 : only uses ssh and scp
-if [ "$duplicity_major" -le 0 -a "$duplicity_minor" -le 4 -a "$duplicity_sub" -lt 2 ]; then
- execstr_options="${execstr_options} --scp-command 'scp $scpoptions' --ssh-command 'ssh $sshoptions'"
-# >= 0.4.2 : also uses sftp, --sftp-command option is now supported
-else
- sftpoptions="$sshoptions"
- # == 0.4.2 : uses ssh, scp and sftp
- if [ "$duplicity_major" -eq 0 -a "$duplicity_minor" -eq 4 -a "$duplicity_sub" -eq 2 ]; then
- execstr_options="${execstr_options} --scp-command 'scp $scpoptions' --sftp-command 'sftp $sftpoptions' --ssh-command 'ssh $sshoptions'"
- # >= 0.4.3 : uses only scp and sftp, --ssh-command option is not supported anymore
- else
- execstr_options="${execstr_options} --scp-command 'scp $scpoptions' --sftp-command 'sftp $sftpoptions'"
- fi
-fi
-
-### Symmetric or asymmetric (public/private key pair) encryption
-if [ -n "$encryptkey" ]; then
- execstr_options="${execstr_options} --encrypt-key $encryptkey"
- debug "Data will be encrypted with the GnuPG key $encryptkey."
-else
- debug "Data will be encrypted using symmetric encryption."
-fi
-
-### Data signing (or not)
-if [ "$sign" == yes ]; then
- # duplicity is not able to sign data when using symmetric encryption
- [ -n "$encryptkey" ] || fatal "The encryptkey option must be set when signing."
- # if needed, initialize signkey to a value that is not empty (checked above)
- [ -n "$signkey" ] || signkey="$encryptkey"
- execstr_options="${execstr_options} --sign-key $signkey"
- debug "Data will be signed will the GnuPG key $signkey."
-else
- debug "Data won't be signed."
-fi
-
-### Incremental or full backup mode
-# If incremental==yes, use the default duplicity behaviour: perform an
-# incremental backup if old signatures can be found, else switch to
-# full backup.
-# If incremental==no, force a full backup anyway.
-if [ "$incremental" == "no" ]; then
- # before 0.4.4, full was an option and not a command
- if [ "$duplicity_major" -le 0 -a "$duplicity_minor" -le 4 -a "$duplicity_sub" -lt 4 ]; then
- execstr_options="${execstr_options} --full"
- else
- execstr_command="full"
- fi
-fi
-
-### Temporary directory
-precmd=
-if [ -n "$tmpdir" ]; then
- if [ ! -d "$tmpdir" ]; then
- info "Temporary directory ($tmpdir) does not exist, creating it."
- mkdir -p "$tmpdir"
- [ $? -eq 0 ] || fatal "Could not create temporary directory ($tmpdir)."
- chmod 0700 "$tmpdir"
- fi
- info "Using $tmpdir as TMPDIR"
- precmd="${precmd}TMPDIR=$tmpdir "
-fi
-
-### Cleanup old backup sets (or not)
-if [ "$keep" != "yes" ]; then
- if [ "`echo $keep | tr -d 0-9`" == "" ]; then
- keep="${keep}D"
- fi
- # before 0.4.4, remove-older-than was an option and not a command
- if [ "$duplicity_major" -le 0 -a "$duplicity_minor" -le 4 -a "$duplicity_sub" -lt 4 ]; then
- execstr_options="${execstr_options} --remove-older-than $keep"
- fi
-fi
-
-### Source
-
-set -o noglob
-
-# excludes
-for i in $exclude; do
- str="${i//__star__/*}"
- execstr_source="${execstr_source} --exclude '$str'"
-done
-
-# includes
-for i in $include; do
- [ "$i" != "/" ] || fatal "Sorry, you cannot use 'include = /'"
- str="${i//__star__/*}"
- execstr_source="${execstr_source} --include '$str'"
-done
-
-# vsincludes
-if [ $usevserver = yes ]; then
- for vserver in $vsnames; do
- for vi in $vsinclude; do
- str="${vi//__star__/*}"
- str="$VROOTDIR/$vserver$str"
- execstr_source="${execstr_source} --include '$str'"
- done
- done
-fi
-
-set +o noglob
-
-### EXECUTE ####################################################################
-
-execstr_source=${execstr_source//\\*/\\\\\\*}
-
-### Cleanup commands (duplicity >= 0.4.4)
-
-# cleanup
-if [ "$duplicity_major" -ge 0 -a "$duplicity_minor" -ge 4 -a "$duplicity_sub" -ge 4 ]; then
- debug "$precmd duplicity cleanup --force $execstr_options $execstr_serverpart"
- if [ ! $test ]; then
- export PASSPHRASE=$password
- output=`nice -n $nicelevel \
- su -c \
- "$precmd duplicity cleanup --force $execstr_options $execstr_serverpart 2>&1"`
- exit_code=$?
- if [ $exit_code -eq 0 ]; then
- debug $output
- info "Duplicity cleanup finished successfully."
- else
- debug $output
- warning "Duplicity cleanup failed."
- fi
- fi
-fi
-
-# remove-older-than
-if [ "$keep" != "yes" ]; then
- if [ "$duplicity_major" -ge 0 -a "$duplicity_minor" -ge 4 -a "$duplicity_sub" -ge 4 ]; then
- debug "$precmd duplicity remove-older-than $keep --force $execstr_options $execstr_serverpart"
- if [ ! $test ]; then
- export PASSPHRASE=$password
- output=`nice -n $nicelevel \
- su -c \
- "$precmd duplicity remove-older-than $keep --force $execstr_options $execstr_serverpart 2>&1"`
- exit_code=$?
- if [ $exit_code -eq 0 ]; then
- debug $output
- info "Duplicity remove-older-than finished successfully."
- else
- debug $output
- warning "Duplicity remove-older-than failed."
- fi
- fi
- fi
-fi
-
-### Backup command
-debug "$precmd duplicity $execstr_command $execstr_options $execstr_source --exclude '**' / $execstr_serverpart"
-if [ ! $test ]; then
- export PASSPHRASE=$password
- output=`nice -n $nicelevel \
- su -c \
- "$precmd duplicity $execstr_command $execstr_options $execstr_source --exclude '**' / $execstr_serverpart 2>&1"`
- exit_code=$?
- if [ $exit_code -eq 0 ]; then
- debug $output
- info "Duplicity finished successfully."
- else
- debug $output
- fatal "Duplicity failed."
- fi
-fi
-
-return 0
diff --git a/handlers/ldap.helper.in b/handlers/ldap.helper.in
deleted file mode 100644
index 9251826..0000000
--- a/handlers/ldap.helper.in
+++ /dev/null
@@ -1,90 +0,0 @@
-# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
-
-HELPERS="$HELPERS ldap:ldap_database_backup"
-
-ldap_create_file() {
-while true; do
- checkBox "ldap action wizard" "check options (slapcat OR ldapsearch)" \
- "slapcat" "export ldif using slapcat" yes \
- "ldapsearch" "export ldif using ldapsearch" no \
- "compress" "compress the ldif output files" yes \
- "ssl" "use SSL (deprecated)" no \
- "tls" "use TLS extended operations (RFC2246, RFC2830)" yes
- status=$?
- compress="compress = no"
- method="method = <unset>"
- restart="restart = no"
- binddn=""
- passwordfile=""
- ssl="ssl = no"
- tls="tls = no"
- [ $status = 1 ] && return;
- result="$REPLY"
- for opt in $result; do
- case $opt in
- '"compress"') compress="compress = yes";;
- '"slapcat"')
- method="method = slapcat"
- [ "$_RESTART" == "yes" ] && restart="restart = yes"
- ;;
- '"ldapsearch"')
- method="method = ldapsearch"
- inputBox "ldap action wizard" "ldapsearch requires authentication. Specify here what password file to use. It must have the password with no trailing return and it should not be world readable."
- [ $? = 1 ] && return
- passwordfile="passwordfile = $REPLY"
- inputBox "ldap action wizard" "ldapsearch requires authentication. Specify here what DN to bind as:"
- [ $? = 1 ] && return
- binddn="binddn = $REPLY"
- require_packages ldap-utils
- ;;
- '"ssl"') ssl="ssl = yes";;
- '"tls"') tls="tls = yes";;
- esac
- done
- get_next_filename $configdirectory/30.ldap
- cat > $next_filename <<EOF
-$method
-$compress
-$restart
-$binddn
-$passwordfile
-$ssl
-$tls
-# backupdir = /var/backups/ldap
-# conf = /etc/ldap/slapd.conf
-# databases = all
-EOF
- chmod 600 $next_filename
- return
-done
-}
-
-ldap_wizard() {
- bdb=no
- hdb=no
- ldbm=no
- for backend in `grep -e "^backend" /etc/ldap/slapd.conf | @AWK@ '{print $2}'`; do
- if [ "$backend" == "bdb" ]; then
- bdb=yes
- elif [ "$backend" == "hdb" ]; then
- hdb=yes
- elif [ "$backend" == "ldbm" ]; then
- ldbm=yes
- fi
- done
-
- if [ "$bdb" == "yes" -o "$hdb" == "yes" ]; then
- if [ "$ldbm" == "no" ]; then
- msgBox "ldap action wizard" "It looks like the backend in your slapd.conf is set to BDB or HDB. If this is not the case, exit this wizard! From this point on, we will assume BDB or HDB backend, which might have disasterious consequences if this is incorrect."
- _RESTART=no
- ldap_create_file
- fi
- elif [ "$ldbm" == "yes" ]; then
- msgBox "ldap action wizard" "It looks like the backend in your slapd.conf is set to LDBM. Because of this, you will have less options (because it is not safe to use slapcat while slapd is running LDBM)."
- _RESTART=yes
- ldap_create_file
- else
- msgBox "ldap action wizard" "I couldn't find any supported backend in your slapd.conf. Bailing out."
- return
- fi
-}
diff --git a/handlers/ldap.in b/handlers/ldap.in
deleted file mode 100644
index 8ff1ccf..0000000
--- a/handlers/ldap.in
+++ /dev/null
@@ -1,111 +0,0 @@
-# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
-#
-# openldap backup handler script for backupninja
-#
-
-getconf backupdir /var/backups/ldap
-getconf conf /etc/ldap/slapd.conf
-getconf databases all
-getconf compress yes
-getconf ldif yes
-getconf restart no
-getconf method ldapsearch
-getconf passwordfile
-getconf binddn
-getconf ldaphost
-getconf ssl yes
-getconf tls no
-
-if [ $ssl = 'yes' ]; then
- URLBASE="ldaps"
-else
- URLBASE="ldap"
-fi
-
-status="ok"
-
-[ -f $conf ] || fatal "slapd config file ($conf) not found"
-[ -d $backupdir ] || mkdir -p $backupdir
-[ -d $backupdir ] || fatal "Backup directory '$backupdir'"
-
-dbsuffixes=(`@AWK@ 'BEGIN {OFS=":"} /[:space:]*^database[:space:]*\w*/ {db=$2}; /^[:space:]*suffix[:space:]*\w*/ {if (db=="bdb"||db=="hdb"||db="ldbm") print db,$2}' $conf|@SED@ -e 's/[" ]//g'`)
-
-## LDIF DUMP
-
-if [ "$ldif" == "yes" ]; then
- dumpdir="$backupdir"
- [ -d $dumpdir ] || mkdir -p $dumpdir
-
- if [ "$databases" == 'all' ]; then
- dbcount=`grep '^database' $conf | wc -l`
- let "dbcount = dbcount - 1"
- databases=`seq 0 $dbcount`;
- fi
-
- for db in $databases; do
- if [ `expr index "$db" "="` == "0" ]; then
- # db is a number, get the suffix.
- dbsuffix=${dbsuffixes[$db]/*:/}
- else
- dbsuffix=$db
- fi
- # some databases don't have suffix (like monitor), skip these
- if [ "$dbsuffix" == "" ]; then
- continue;
- fi
-
- if [ "$method" == "slapcat" ]; then
- execstr="$SLAPCAT -f $conf -b $dbsuffix"
- else
- LDAPARGS=""
- if [ "$tls" == "yes" ]; then
- LDAPARGS="-ZZ"
- fi
- if [ -n "$ldaphost" ]; then
- execstr="$LDAPSEARCH $LDAPARGS -H $URLBASE://$ldaphost -x -L -b ""$dbsuffix"" -D ""$binddn"" -y $passwordfile"
- else
- execstr="$LDAPSEARCH -H $URLBASE://$ldaphost -x -L -b ""$dbsuffix"" -D ""$binddn"" -y $passwordfile"
- fi
- [ -f "$passwordfile" ] || fatal "Password file $passwordfile not found. When method is set to ldapsearch, you must also specify a password file."
- debug "$execstr"
- fi
- if [ ! $test ]; then
- if [ "$restart" == "yes" ]; then
- debug "Shutting down ldap server..."
- /etc/init.d/slapd stop
- fi
-
- ext=
- if [ "$compress" == "yes" ]; then
- ext=".gz"
- fi
- touch $dumpdir/$dbsuffix.ldif$ext
- if [ ! -f $dumpdir/$dbsuffix.ldif$ext ]; then
- fatal "Couldn't create ldif dump file: $dumpdir/$dbsuffix.ldif$ext"
- fi
-
- if [ "$compress" == "yes" ]; then
- execstr="$execstr | $GZIP > $dumpdir/$dbsuffix.ldif.gz"
- else
- execstr="$execstr > $dumpdir/$dbsuffix.ldif"
- fi
- debug "$execstr"
- output=`su root -c "$execstr" 2>&1`
- code=$?
- if [ "$code" == "0" ]; then
- debug $output
- info "Successfully finished ldif export of $dbsuffix"
- else
- warning $output
- warning "Failed ldif export of $dbsuffix"
- fi
-
- if [ "$restart" == "yes" ]; then
- debug "Starting ldap server..."
- /etc/init.d/slapd start
- fi
- fi
- done
-fi
-
-return 0
diff --git a/handlers/maildir.in b/handlers/maildir.in
deleted file mode 100644
index d5731be..0000000
--- a/handlers/maildir.in
+++ /dev/null
@@ -1,370 +0,0 @@
-# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
-
-###############################################################
-#
-# This handler slowly creates a backup of each user's maildir
-# to a remote server. It is designed to be run with low overhead
-# in terms of cpu and bandwidth so it runs pretty slow.
-# Hardlinking is used to save storage space.
-#
-# This handler expects that your maildir directory structure is
-# either one of the following:
-#
-# 1. /$srcdir/[a-zA-Z0-9]/$user for example:
-# /var/maildir/a/anarchist
-# /var/maildir/a/arthur
-# ...
-# /var/maildir/Z/Zaphod
-# /var/maildir/Z/Zebra
-#
-# 2. or the following:
-# /var/maildir/domain.org/user1
-# /var/maildir/domain.org/user2
-# ...
-# /var/maildir/anotherdomain.org/user1
-# /var/maildir/anotherdomain.org/user2
-# ...
-#
-# if the configuration is setup to have keepdaily at 3,
-# keepweekly is 2, and keepmonthly is 1, then each user's
-# maildir backup snapshot directory will contain these files:
-# daily.1
-# daily.2
-# daily.3
-# weekly.1
-# weekly.2
-# monthly.1
-#
-# The basic algorithm is to rsync each maildir individually,
-# and to use hard links for retaining historical data.
-#
-# We handle each maildir individually because it becomes very
-# unweldy to hardlink and rsync many hundreds of thousands
-# of files at once. It is much faster to take on smaller
-# chunks at a time.
-#
-# For the backup rotation to work, destuser must be able to run
-# arbitrary bash commands on the desthost.
-#
-# Any maildir which is deleted from the source will be moved to
-# "deleted" directory in the destination. It is up to you to
-# periodically remove this directory or old maildirs in it.
-#
-##############################################################
-
-getconf rotate yes
-getconf remove yes
-getconf backup yes
-
-getconf loadlimit 5
-getconf speedlimit 0
-getconf keepdaily 5
-getconf keepweekly 3
-getconf keepmonthly 1
-
-getconf srcdir /var/maildir
-getconf destdir
-getconf desthost
-getconf destport 22
-getconf destuser
-getconf destid_file /root/.ssh/id_rsa
-
-getconf multiconnection notset
-
-failedcount=0
-# strip trailing /
-destdir=${destdir%/}
-srcdir=${srcdir%/}
-
-[ -d $srcdir ] || fatal "source directory $srcdir doesn't exist"
-
-[ "$multiconnection" == "notset" ] && fatal "The maildir handler uses a very different destination format. See the example .maildir for more information"
-
-if [ $test ]; then
- testflags="--dry-run -v"
-fi
-
-rsyncflags="$testflags -e 'ssh -p $destport -i $destid_file' -r -v --ignore-existing --delete --size-only --bwlimit=$speedlimit"
-excludes="--exclude '.Trash/\*' --exclude '.Mistakes/\*' --exclude '.Spam/\*'"
-
-##################################################################
-### FUNCTIONS
-
-function do_user() {
- local user=$1
- local btype=$2
- local userdir=${3%/}
- local source="$srcdir/$userdir/$user/"
- local target="$destdir/$userdir/$user/$btype.1"
- if [ ! -d $source ]; then
- warning "maildir $source not found"
- return
- fi
-
- debug "syncing"
- ret=`$RSYNC -e "ssh -p $destport -i $destid_file" -r \
- --links --ignore-existing --delete --size-only --bwlimit=$speedlimit \
- --exclude '.Trash/*' --exclude '.Mistakes/*' --exclude '.Spam/*' \
- $source $destuser@$desthost:$target \
- 2>&1`
- ret=$?
- # ignore 0 (success) and 24 (file vanished before it could be copied)
- if [ $ret != 0 -a $ret != 24 ]; then
- warning "rsync $user failed"
- warning " returned: $ret"
- let "failedcount = failedcount + 1"
- if [ $failedcount -gt 100 ]; then
- fatal "100 rsync errors -- something is not working right. bailing out."
- fi
- fi
- ssh -o PasswordAuthentication=no $desthost -l $destuser -i $destid_file "date +%c%n%s > $target/created"
-}
-
-# remove any maildirs from backup which might have been deleted
-# and add new ones which have just been created.
-# (actually, it just moved them to the directory "deleted")
-
-function do_remove() {
- local tmp1=`maketemp maildir-tmp-file`
- local tmp2=`maketemp maildir-tmp-file`
-
- ssh -p $destport -i $destid_file $destuser@$desthost mkdir -p "$destdir/deleted"
- cd "$srcdir"
- for userdir in `ls -d1 */`; do
- ls -1 "$srcdir/$userdir" | sort > $tmp1
- ssh -p $destport -i $destid_file $destuser@$desthost ls -1 "$destdir/$userdir" | sort > $tmp2
- for deluser in `join -v 2 $tmp1 $tmp2`; do
- [ "$deluser" != "" ] || continue
- info "removing $destuser@$desthost:$destdir/$userdir$deluser/"
- ssh -p $destport -i $destid_file $destuser@$desthost mv "$destdir/$userdir$deluser/" "$destdir/deleted"
- ssh -p $destport -i $destid_file $destuser@$desthost "date +%c%n%s > '$destdir/deleted/$deluser/deleted_on'"
- done
- done
- rm $tmp1
- rm $tmp2
-}
-
-function do_rotate() {
- [ "$rotate" == "yes" ] || return;
- local user=$1
- local userdir=${2%/}
- local backuproot="$destdir/$userdir/$user"
-(
- ssh -T -o PasswordAuthentication=no $desthost -l $destuser -i $destid_file <<EOF
-##### BEGIN REMOTE SCRIPT #####
- seconds_daily=86400
- seconds_weekly=604800
- seconds_monthly=2628000
- keepdaily=$keepdaily
- keepweekly=$keepweekly
- keepmonthly=$keepmonthly
- now=\`date +%s\`
-
- if [ ! -d "$backuproot" ]; then
- echo "Debug: skipping rotate of $user. $backuproot doesn't exist."
- exit
- fi
- for rottype in daily weekly monthly; do
- seconds=\$((seconds_\${rottype}))
-
- dir="$backuproot/\$rottype"
- if [ ! -d \$dir.1 ]; then
- echo "Debug: \$dir.1 does not exist, skipping."
- continue 1
- elif [ ! -f \$dir.1/created ]; then
- echo "Warning: \$dir.1/created does not exist. This backup may be only partially completed. Skipping rotation."
- continue 1
- fi
-
- # Rotate the current list of backups, if we can.
- oldest=\`find $backuproot -maxdepth 1 -type d -name \$rottype'.*' | @SED@ 's/^.*\.//' | sort -n | tail -1\`
- #echo "Debug: oldest \$oldest"
- [ "\$oldest" == "" ] && oldest=0
- for (( i=\$oldest; i > 0; i-- )); do
- if [ -d \$dir.\$i ]; then
- if [ -f \$dir.\$i/created ]; then
- created=\`tail -1 \$dir.\$i/created\`
- else
- created=0
- fi
- cutoff_time=\$(( now - (seconds*(i-1)) ))
- if [ ! \$created -gt \$cutoff_time ]; then
- next=\$(( i + 1 ))
- if [ ! -d \$dir.\$next ]; then
- echo "Debug: \$rottype.\$i --> \$rottype.\$next"
- mv \$dir.\$i \$dir.\$next
- date +%c%n%s > \$dir.\$next/rotated
- else
- echo "Debug: skipping rotation of \$dir.\$i because \$dir.\$next already exists."
- fi
- else
- echo "Debug: skipping rotation of \$dir.\$i because it was created" \$(( (now-created)/86400)) "days ago ("\$(( (now-cutoff_time)/86400))" needed)."
- fi
- fi
- done
- done
-
- max=\$((keepdaily+1))
- if [ \( \$keepweekly -gt 0 -a -d $backuproot/daily.\$max \) -a ! -d $backuproot/weekly.1 ]; then
- echo "Debug: daily.\$max --> weekly.1"
- mv $backuproot/daily.\$max $backuproot/weekly.1
- date +%c%n%s > $backuproot/weekly.1/rotated
- fi
-
- max=\$((keepweekly+1))
- if [ \( \$keepmonthly -gt 0 -a -d $backuproot/weekly.\$max \) -a ! -d $backuproot/monthly.1 ]; then
- echo "Debug: weekly.\$max --> monthly.1"
- mv $backuproot/weekly.\$max $backuproot/monthly.1
- date +%c%n%s > $backuproot/monthly.1/rotated
- fi
-
- for rottype in daily weekly monthly; do
- max=\$((keep\${rottype}+1))
- dir="$backuproot/\$rottype"
- oldest=\`find $backuproot -maxdepth 1 -type d -name \$rottype'.*' | @SED@ 's/^.*\.//' | sort -n | tail -1\`
- [ "\$oldest" == "" ] && oldest=0
- # if we've rotated the last backup off the stack, remove it.
- for (( i=\$oldest; i >= \$max; i-- )); do
- if [ -d \$dir.\$i ]; then
- if [ -d $backuproot/rotate.tmp ]; then
- echo "Debug: removing rotate.tmp"
- rm -rf $backuproot/rotate.tmp
- fi
- echo "Debug: moving \$rottype.\$i to rotate.tmp"
- mv \$dir.\$i $backuproot/rotate.tmp
- fi
- done
- done
-####### END REMOTE SCRIPT #######
-EOF
-) | (while read a; do passthru $a; done)
-
-}
-
-
-function setup_remote_dirs() {
- local user=$1
- local backuptype=$2
- local userdir=${3%/}
- local dir="$destdir/$userdir/$user/$backuptype"
- local tmpdir="$destdir/$userdir/$user/rotate.tmp"
-(
- ssh -T -o PasswordAuthentication=no $desthost -l $destuser -i $destid_file <<EOF
- if [ ! -d $destdir ]; then
- echo "Fatal: Destination directory $destdir does not exist on host $desthost."
- exit 1
- elif [ -d $dir.1 ]; then
- if [ -f $dir.1/created ]; then
- echo "Warning: $dir.1 already exists. Overwriting contents."
- else
- echo "Warning: we seem to be resuming a partially written $dir.1"
- fi
- else
- if [ -d $tmpdir ]; then
- mv $tmpdir $dir.1
- if [ \$? == 1 ]; then
- echo "Fatal: could mv $destdir/rotate.tmp $dir.1 on host $desthost"
- exit 1
- fi
- else
- mkdir --parents $dir.1
- if [ \$? == 1 ]; then
- echo "Fatal: could not create directory $dir.1 on host $desthost"
- exit 1
- fi
- fi
- if [ -d $dir.2 ]; then
- echo "Debug: update links $backuptype.2 --> $backuptype.1"
- cp -alf $dir.2/. $dir.1
- #if [ \$? == 1 ]; then
- # echo "Fatal: could not create hard links to $dir.1 on host $desthost"
- # exit 1
- #fi
- fi
- fi
- [ -f $dir.1/created ] && rm $dir.1/created
- [ -f $dir.1/rotated ] && rm $dir.1/rotated
- exit 0
-EOF
-) | (while read a; do passthru $a; done)
-
- if [ $? == 1 ]; then exit; fi
-}
-
-function start_mux() {
- if [ "$multiconnection" == "yes" ]; then
- debug "Starting dummy ssh connection"
- ssh -p $destport -i $destid_file $destuser@$desthost sleep 1d &
- sleep 1
- fi
-}
-
-function end_mux() {
- if [ "$multiconnection" == "yes" ]; then
- debug "Stopping dummy ssh connection"
- ssh -p $destport -i $destid_file $destuser@$desthost pkill sleep
- fi
-}
-
-###
-##################################################################
-
-# see if we can login
-debug "ssh -o PasswordAuthentication=no $desthost -l $destuser -i $destid_file 'echo -n 1'"
-if [ ! $test ]; then
- result=`ssh -o PasswordAuthentication=no $desthost -l $destuser -i $destid_file 'echo -n 1' 2>&1`
- if [ "$result" != "1" ]; then
- fatal "Can't connect to $desthost as $destuser using $destid_file."
- fi
-fi
-
-end_mux
-start_mux
-
-## SANITY CHECKS ##
-status=`ssh -p $destport -i $destid_file $destuser@$desthost "[ -d \"$destdir\" ] && echo 'ok'"`
-if [ "$status" != "ok" ]; then
- end_mux
- fatal "Destination directory $destdir doesn't exist!"
- exit
-fi
-
-### REMOVE OLD MAILDIRS ###
-
-if [ "$remove" == "yes" ]; then
- do_remove
-fi
-
-### MAKE BACKUPS ###
-
-if [ "$backup" == "yes" ]; then
- if [ $keepdaily -gt 0 ]; then btype=daily
- elif [ $keepweekly -gt 0 ]; then btype=weekly
- elif [ $keepmonthly -gt 0 ]; then btype=monthly
- else fatal "keeping no backups"; fi
-
- if [ "$testuser" != "" ]; then
- cd "$srcdir/${user:0:1}"
- do_rotate $testuser
- setup_remote_dirs $testuser $btype
- do_user $testuser $btype
- else
- [ -d "$srcdir" ] || fatal "directory $srcdir not found."
- cd "$srcdir"
- for userdir in `ls -d1 */`; do
- [ -d "$srcdir/$userdir" ] || fatal "directory $srcdir/$userdir not found."
- cd "$srcdir/$userdir"
- debug $userdir
- for user in `ls -1`; do
- [ "$user" != "" ] || continue
- debug "$user $userdir"
- do_rotate $user $userdir
- setup_remote_dirs $user $btype $userdir
- do_user $user $btype $userdir
- done
- done
- fi
-fi
-
-end_mux
-
diff --git a/handlers/makecd.helper.in b/handlers/makecd.helper.in
deleted file mode 100644
index f83b541..0000000
--- a/handlers/makecd.helper.in
+++ /dev/null
@@ -1,97 +0,0 @@
-# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
-
-HELPERS="$HELPERS makecd:makecd_backup"
-wizardname="makecd action wizard"
-
-declare -a makecd_excludes
-
-makecd_wizard() {
-
- inputBox "$wizardname" "specify a burner type cd or dvd:"
- [ $? = 1 ] && return
- burnertype="burnertype = $REPLY"
-
- booleanBox "$wizardname" "Make iso image only? or burn"
- if [ $? = 0 ]; then
- isoonly="isoonly = yes"
- else
- isoonly="isoonly = no"
- fi
-
- # backupdir
- inputBox "$wizardname" "Directory where to store the backups:"
- [ $? = 1 ] && return
- backupdir="backupdir = $REPLY"
-
- inputBox "$wizardname" "what name to give to the image file?"
- [ $? = 1 ] && return
- imagefile="imagefile = $REPLY"
-
- inputBox "$wizardname" "specify a burner device:"
- [ $? = 1 ] && return
- device="device = $REPLY"
-
- # target - root of system to be included
- inputBox "$wizardname" "root of filesystem for burn:"
- [ $? = 1 ] && return
- target="target = $REPLY"
-
-
- # excludes
-
- formBegin "$wizardname: excludes"
- for ((i=0; i < ${#makecd_excludes[@]} ; i++)); do
- formItem exclude ${makecd_excludes[$i]}
- done
- formItem exclude
- formItem exclude
- formItem exclude
- formItem exclude
- formItem exclude
- formItem exclude
- formItem exclude
- formItem exclude
- formItem exclude
- formDisplay
- [ $? = 1 ] && return;
-
- unset makecd_excludes
- makecd_excludes=($REPLY)
-
- get_next_filename $configdirectory/20.makecd
- cat >> $next_filename <<EOF
-
-# TYP is cd or dvd AS WELL AS the disk inside!!
-$burnertype
-
-# not yet supported
-system = no
-
-# iso or burn to cd/dvd?
-$isoonly
-
-# location for image file
-$backupdir
-
-# image filename
-$imagefile
-
-# cd/dvd burner device
-$device
-
-# dirs/files to include in the backup
-$target
-
-# directories/files to be excluded
-# exclude = /proc
-# exclude = /sys
-# exclude = /dev
-EOF
-
- for ((j=0; j < ${#makecd_excludes[@]} ; j++)); do
- echo "exclude = ${makecd_excludes[$j]}" >> $next_filename
- done
-
- chmod 600 $next_filename
-}
-
diff --git a/handlers/makecd.in b/handlers/makecd.in
deleted file mode 100644
index 1a95d6d..0000000
--- a/handlers/makecd.in
+++ /dev/null
@@ -1,88 +0,0 @@
-# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
-#
-# burncd handler script for backupninja
-#
-getconf backupdir /var/backups/makecd
-getconf exclude
-getconf target
-getconf burnertype cd
-getconf system no
-getconf isoonly yes
-getconf imagefile backup.iso
-getconf device
-getconf nicelevel 0
-
-# define needed executables:
-MKISOFS="/usr/bin/genisoimage"
-GROWISOFS="/usr/bin/growisofs"
-CDRECORD="/usr/bin/wodim"
-CDRDAO="/usr/bin/cdrdao"
-DVDINFO="/usr/bin/dvd+rw-mediainfo"
-
-# create backup dirs and check existence of progs.
-
-[ -d $backupdir ] || mkdir -p $backupdir
-[ -d $backupdir ] || fatal "Backup directory '$backupdir'"
-[ -e "$target" ] || fatal "target does not exist "
-
-[ -x "$MKISOFS" ] || debug 3 "echo executable $MKISOFS not present"
-[ -x "$GROWISOFS" ] || debug 3 "echo executable $GROWISOFS not present"
-[ -x "$CDRECORD" ] || debug 3 "echo executable $CDRECORD not present"
-[ -x "$CDRDAO" ] || debug 3 "echo executable $CDRDAO not present"
-
-if [ "$isoonly" == "no" ]; then
- [ -e $device ] || fatal "No Burner device available"
-fi
-
-outputfile="$backupdir/$imagefile"
-execstr="nice -n $nicelevel $MKISOFS --quiet -R -o $outputfile "
-
-str=""
-# excludes
-for i in $exclude; do
- str=" -x ${i}$str"
-done
-
-debug 0 "echo $str "
-execstr="${execstr} $str $target "
-debug 0 "echo $execstr "
-
-output=` $execstr 2>&1 `
-code=$?
-if [ "$code" == "0" ]; then
- debug $output
- info "Successfully finished creation of iso"
-else
- warning $output
- warning "Failed to create iso"
-fi
-
-if [ "$isoonly" == "no" ]; then
-
- if [ "$burnertype" == "cd" ]; then
- # burning iso to CD
- $CDRECORD -v gracetime=2 dev=$device speed=8 -dao -data $outputfile
- code=$?
- if [ "$code" == "0" ]; then
- debug $output
- info "Successfully burned CD"
- else
- warning $output
- warning "Failed to create CD"
- fi
- fi
- if [ "$burnertype" == "dvd" ]; then
- # burning iso dvd
- $GROWISOFS -speed=2 -Z $device=$outputfile -use-the-force-luke=notray -use-the-force-luke=tty
- code=$?
- if [ "$code" == "0" ]; then
- debug $output
- info "Successfully burned DVD"
- else
- warning $output
- warning "Failed to create DVD"
- fi
- fi
-fi
-return 0
-
diff --git a/handlers/mysql.helper.in b/handlers/mysql.helper.in
deleted file mode 100644
index 00eeca0..0000000
--- a/handlers/mysql.helper.in
+++ /dev/null
@@ -1,217 +0,0 @@
-# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
-
-HELPERS="$HELPERS mysql:mysql_database_backup"
-
-do_mysql_vserver() {
- choose_one_vserver "$mysql_title"
- [ $? = 0 ] || return 1
- mysql_vsname="vsname = $REPLY"
-}
-
-do_mysql_databases() {
- REPLY=
- while [ -z "$REPLY" ]; do
- formBegin "$mysql_title: databases"
- formItem "Database:"
- formItem "Database:"
- formItem "Database:"
- formItem "Database:"
- formItem "Database:"
- formItem "Database:"
- formItem "Database:"
- formItem "Database:"
- formItem "Database:"
- formItem "Database:"
- formDisplay
- [ $? = 0 ] || return 1
- mysql_databases="databases = "
- for i in $REPLY; do
- [ -n "$i" ] && mysql_databases="$mysql_databases $i"
- done
- done
-}
-
-do_mysql_password() {
- inputBox "$mysql_title" "specify a mysql user:"
- [ $? = 1 ] && return
- user=$REPLY
- inputBox "$mysql_title" "specify the mysql user's password:"
- [ $? = 1 ] && return
- password=$REPLY
- do_mysql_final "dbusername = $user\ndbpassword = $password"
-}
-
-do_mysql_debian() {
- _DISABLE_HOTCOPY=yes
- do_mysql_final "configfile = /etc/mysql/debian.cnf"
-}
-
-do_mysql_user() {
- inputBox "$mysql_title" "what system user does mysql backup use?"
- [ $? = 1 ] && return
- do_mysql_final "user = $REPLY"
-}
-
-do_mysql_final() {
- if [ -z "$_DISABLE_HOTCOPY" ]; then
- checkBox "$mysql_title" "check options" \
- "sqldump" "create a backup using mysqldump (more compat)." no \
- "hotcopy" "create a backup using mysqlhotcopy (faster)." yes \
- "compress" "compress the sql output files" yes
- status=$?
- sqldump="sqldump = no"
- hotcopy="hotcopy = no"
- else
- checkBox "$mysql_title" "check options" \
- "compress" "compress the sql output files" yes
- status=$?
- sqldump="sqldump = yes"
- hotcopy="hotcopy = no"
- fi
-
- [ $status = 1 ] && return;
- result="$REPLY"
- compress="compress = no"
- for opt in $result; do
- case $opt in
- '"sqldump"') sqldump="sqldump = yes";;
- '"hotcopy"') hotcopy="hotcopy = yes";;
- '"compress"') compress="compress = yes";;
- esac
- done
- get_next_filename $configdirectory/20.mysql
-
- cat >> $next_filename <<EOF
-### backupninja MySQL config file ###
-
-# hotcopy = < yes | no > (default = no)
-# make a backup of the actual database binary files using mysqlhotcopy.
-$hotcopy
-
-# sqldump = < yes | no > (default = no)
-# make a backup using mysqldump. this creates text files with sql commands
-# sufficient to recontruct the database.
-#
-$sqldump
-
-# sqldumpoptions = <options>
-# (default = --lock-tables --complete-insert --add-drop-table --quick --quote-names)
-# arguments to pass to mysqldump
-# sqldumpoptions = --add-drop-table --quick --quote-names
-
-# compress = < yes | no > (default = yes)
-# if yes, compress the sqldump output.
-$compress
-
-# dbhost = <host> (default = localhost)
-
-EOF
- cat >> $next_filename <<EOF
-
-# backupdir = <dir> (default: /var/backups/mysql)
-# where to dump the backups. hotcopy backups will be in a subdirectory
-# 'hotcopy' and sqldump backups will be in a subdirectory 'sqldump'
-$mysql_backupdir
-
-# databases = <all | db1 db2 db3 > (default = all)
-# which databases to backup. should either be the word 'all' or a
-# space separated list of database names.
-$mysql_databases
-
-EOF
-
-if [ $host_or_vservers == vservers ]
- then
- cat >> $next_filename <<EOF
-#
-# vsname = <vserver> (no default)
-# vsname indicates which vserver to operate on, this is only used if
-# vserver is set to yes in /etc/backupninja.conf
-# NOTE: if you do not specify a vsname the host will be operated on
-# alsoNOTE: if operating on a vserver, $VROOTDIR will be
-# prepended to backupdir.
-EOF
- echo -e "$mysql_vsname\n" >> $next_filename
-fi
-
- echo -e $@ >> $next_filename
-
- chmod 600 $next_filename
-}
-
-mysql_wizard() {
-
- # Global variables
- mysql_title="MySQL action wizard"
-
- # backup the host system or a Vserver?
- choose_host_or_one_vserver "$mysql_title"
- [ $? = 0 ] || return 1
- if [ $host_or_vservers == vservers ]
- then
- do_mysql_vserver
- [ $? = 0 ] || return 1
- fi
-
- # backupdir
- if [ $host_or_vservers == vservers ]
- then
- inputBox "$mysql_title" "Directory where to store the backups:`echo \"\n(Relative to chosen vserver's root directory)\"`" "/var/backups/mysql"
- else
- inputBox "$mysql_title" "Directory where to store the backups" "/var/backups/mysql"
- fi
- [ $? = 1 ] && return
- mysql_backupdir="backupdir = $REPLY"
-
- # databases
- booleanBox "$mysql_title" "Do you want to backup all of the databases? `echo \"\n\nIf not, you'll be offered to choose individual databases to backup.\"`"
- if [ $? = 0 ]; then
- mysql_databases="databases = all"
- else
- do_mysql_databases
- [ $? = 0 ] || return 1
- fi
-
- while true; do
- _DISABLE_HOTCOPY=
- menuBoxHelpFile "$mysql_title" "choose a mysql authentication method:" \
- user "change to a linux user first." \
- password "manually specify mysql user and password." \
- debian "use default mysql user debian-sys-maint."
- status=$?
- if [ $status = 2 ]; then
- # show help.
- helptmp="/tmp/backupninja.help.$$"
- cat > $helptmp <<EOF
-To connect to mysql, backupninja must authenticate.
-There are three possible authentication methods:
-
-USER
-With this method, you specify a system user. Backupninja will
-then become this user before running mysqldump or mysqlhotcopy.
-The result is that ~/.my.cnf is used for authentication.
-
-PASSWORD
-With this method, you manually specify a mysql user and
-password in the backup action configuration.
-
-DEBIAN
-With this method, we use the debian-sys-maint user which is
-already defined in /etc/mysql/debian.cnf. If you are running
-debian, this is recommended, because no further configuration
-is needed. The drawback is that this is incompatible with
-mysqlhotcopy: you must use mysqldump.
-EOF
- dialog --textbox $helptmp 0 0
- rm $helptmp
- fi
-
- [ $status = 1 ] && return;
- result="$REPLY"
- case "$result" in
- "user") do_mysql_user;return;;
- "password") do_mysql_password;return;;
- "debian") do_mysql_debian;return;;
- esac
- done
-}
diff --git a/handlers/mysql.in b/handlers/mysql.in
deleted file mode 100644
index e34b16d..0000000
--- a/handlers/mysql.in
+++ /dev/null
@@ -1,320 +0,0 @@
-# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
-#
-# mysql handler script for backupninja
-#
-
-getconf backupdir /var/backups/mysql
-getconf databases all
-getconf ignores
-getconf nodata
-getconf dbhost localhost
-getconf hotcopy no
-getconf sqldump no
-getconf sqldumpoptions "--lock-tables --complete-insert --add-drop-table --quick --quote-names"
-getconf compress yes
-getconf vsname
-
-# authentication:
-getconf user
-getconf dbusername
-getconf dbpassword
-getconf configfile /etc/mysql/debian.cnf
-
-
-# Decide if the handler should operate on a vserver or on the host.
-# In the former case, check that $vsname exists and is running.
-local usevserver=no
-local vroot
-if [ $vservers_are_available = yes ]; then
- if [ -n "$vsname" ]; then
- # does it exist ?
- if ! vservers_exist "$vsname" ; then
- fatal "The vserver given in vsname ($vsname) does not exist."
- fi
- # is it running ?
- vservers_running $vsname || fatal "The vserver $vsname is not running."
- # everything ok
- info "Using vserver '$vsname'."
- usevserver=yes
- vroot="$VROOTDIR/$vsname"
- else
- info "No vserver name specified, actions will be performed on the host."
- fi
-fi
-
-## Prepare ignore part of the command
-## This only works for mysqldump at the moment
-
-ignore=''
-for i in $ignores $nodata; do
- ignore="$ignore --ignore-table=$i"
-done
-
-# create backup dirs, $vroot will be empty if no vsname was specified
-# and we will instead proceed to operate on the host
-[ -d $vroot$backupdir ] || mkdir -p $vroot$backupdir
-[ -d $vroot$backupdir ] || fatal "Backup directory '$vroot$backupdir'"
-hotdir="$backupdir/hotcopy"
-dumpdir="$backupdir/sqldump"
-
-if [ $usevserver = yes ]
-then
- [ "$sqldump" == "no" -o -d $vroot$dumpdir ] || $VSERVER $vsname exec mkdir -p $dumpdir
- [ "$hotcopy" == "no" -o -d $vroot$hotdir ] || $VSERVER $vsname exec mkdir -p $hotdir
-else
- [ "$sqldump" == "no" -o -d $dumpdir ] || mkdir -p $dumpdir
- [ "$hotcopy" == "no" -o -d $hotdir ] || mkdir -p $hotdir
-fi
-
-#######################################################################
-## AUTHENTICATION
-
-#
-# one of three authentication methods:
-# 1. setting the user, so that /home/user/.my.cnf is used.
-# 2. specifying the user and password in the handler config,
-# which generates a temporary .my.cnf in /root/.my.cnf
-# 3. specify the config file with --defaults-extra-file
-# (this option DOESN'T WORK WITH MYSQLHOTCOPY)
-#
-
-# create .my.cnf
-# only if dbusername and dbpassword specified.
-# we create a tmp file because we don't want to
-# specify the password on the command line.
-
-defaultsfile=""
-
-if [ "$dbusername" != "" -a "$dbpassword" != "" ]
-then
- if [ $usevserver = yes ]
- then
- vhome=`$VSERVER $vsname exec getent passwd "root" | @AWK@ -F: '{print $6}'`
- home="$vroot$vhome"
- else
- home=`getent passwd "root" | @AWK@ -F: '{print $6}'`
- fi
-
- [ -d $home ] || fatal "Can't find root's home directory ($home)."
-
- mycnf="$home/.my.cnf"
-
- if [ -f $mycnf ]
- then
- # rename temporarily
- tmpcnf="$home/my.cnf.disable"
- debug "mv $mycnf $tmpcnf"
- mv $mycnf $tmpcnf
- fi
-
- oldmask=`umask`
- umask 077
- cat > $mycnf <<EOF
-# auto generated backupninja mysql conf
-[mysql]
-host=$dbhost
-user=$dbusername
-password="$dbpassword"
-
-[mysqldump]
-host=$dbhost
-user=$dbusername
-password="$dbpassword"
-
-[mysqlhotcopy]
-host=$dbhost
-user=$dbusername
-password="$dbpassword"
-EOF
- umask $oldmask
- if [ $usevserver = yes ]
- then
- defaultsfile="--defaults-extra-file=$vhome/.my.cnf"
- else
- defaultsfile="--defaults-extra-file=$mycnf"
- fi
-fi
-
-# if a user is not set, use $configfile, otherwise use $mycnf
-if [ "$user" == "" ]; then
- user=root;
- defaultsfile="--defaults-extra-file=$configfile"
-else
- userset=true;
- if [ $usevserver = yes ]
- then
- vuserhome=`$VSERVER $vsname exec getent passwd "$user" | @AWK@ -F: '{print $6}'`
- if [ $? -eq 2 ]
- then
- fatal "User $user not found in /etc/passwd"
- fi
- userhome="$vroot$vuserhome"
- else
- userhome=`getent passwd "$user" | @AWK@ -F: '{print $6}'`
- if [ $? -eq 2 ]
- then
- fatal "User $user not found in /etc/passwd"
- fi
- fi
-
- debug "User home set to: $userhome"
- [ -f $userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf"
- defaultsfile="--defaults-extra-file=$userhome/.my.cnf"
- debug "using $defaultsfile"
-fi
-
-#######################################################################
-## HOT COPY
-
-if [ "$hotcopy" == "yes" ]
-then
- info "Initializing hotcopy method"
- if [ "$databases" == "all" ]
- then
- if [ $usevserver = yes ]
- then
- info "dbhost: $dbhost"
- execstr="$VSERVER $vsname exec $MYSQLHOTCOPY -h $dbhost --quiet --allowold --regexp /.\*/./.\*/ $hotdir"
- else
- execstr="$MYSQLHOTCOPY --quiet --allowold --regexp /.\*/./.\*/ $hotdir"
- fi
- debug "su $user -c \"$execstr\""
- if [ ! $test ]
- then
- output=`su $user -c "$execstr" 2>&1`
- code=$?
- if [ "$code" == "0" ]
- then
- debug $output
- info "Successfully finished hotcopy of all mysql databases"
- else
- warning $output
- warning "Failed to hotcopy all mysql databases"
- fi
- fi
- else
- for db in $databases
- do
- if [ $usevserver = yes ]
- then
- execstr="$VSERVER $vsname exec $MYSQLHOTCOPY --allowold $db $hotdir"
- else
- execstr="$MYSQLHOTCOPY --allowold $db $hotdir"
- fi
- debug 'su $user -c \"$execstr\"'
- if [ ! $test ]
- then
- output=`su $user -c "$execstr" 2>&1`
- code=$?
- if [ "$code" == "0" ]
- then
- debug $output
- info "Successfully finished hotcopy of mysql database $db"
- else
- warning $output
- warning "Failed to hotcopy mysql database $db"
- fi
- fi
- done
- fi
-fi
-
-##########################################################################
-## SQL DUMP
-
-if [ "$sqldump" == "yes" ]
-then
- info "Initializing SQL dump method"
- if [ "$databases" == "all" ]
- then
- if [ $usevserver = yes ]
- then
- debug 'echo show databases | $VSERVER $vsname exec su $user -c \"$MYSQL $defaultsfile\" | grep -v Database'
- databases=`echo 'show databases' | $VSERVER $vsname exec su $user -c "$MYSQL $defaultsfile" | grep -v Database`
- if [ $? -ne 0 ]
- then
- fatal "Authentication problem, maybe user/password is wrong or mysqld is not running?"
- fi
- else
- databases=$(su $user -c "$MYSQL $defaultsfile -N -B -e 'show databases'" | sed 's/|//g;/\+----/d')
- if [ $? -ne 0 ]
- then
- fatal "Authentication problem, maybe user/password is wrong or mysqld is not running?"
- fi
- fi
- fi
-
- for db in $databases
- do
- DUMP_BASE="$MYSQLDUMP $defaultsfile $sqldumpoptions"
-
- # Dumping structure and data
- DUMP="$DUMP_BASE $ignore $db"
-
- # If requested, dump only the table structure for this database
- if echo "$nodata" | grep -E '(^|[[:space:]])'"$db\." >/dev/null
- then
- # Get the structure of the tables, without data
- DUMP_STRUCT="$DUMP_BASE --no-data $db"
- for qualified_table in $nodata
- do
- table=$( expr match "$qualified_table" "$db\.\([^\w]*\)" )
- DUMP_STRUCT="$DUMP_STRUCT $table"
- done
- DUMP="( $DUMP; $DUMP_STRUCT )"
- fi
- if [ $usevserver = yes ]
- then
- # Test to make sure mysqld is running, if it is not sqldump will not work
- $VSERVER $vsname exec su $user -c "$MYSQLADMIN $defaultsfile ping 2>&1 >/dev/null"
- if [ $? -ne 0 ]; then
- fatal "mysqld doesn't appear to be running!"
- fi
- if [ "$compress" == "yes" ]; then
- execstr="$VSERVER $vsname exec $DUMP | $GZIP > $vroot$dumpdir/${db}.sql.gz"
- else
- execstr="$VSERVER $vsname exec $DUMP -r $vroot$dumpdir/${db}.sql"
- fi
- else
- # Test to make sure mysqld is running, if it is not sqldump will not work
- su $user -c "$MYSQLADMIN $defaultsfile ping 2>&1 >/dev/null"
- if [ $? -ne 0 ]; then
- fatal "mysqld doesn't appear to be running!"
- fi
- if [ "$compress" == "yes" ]; then
- execstr="$DUMP | $GZIP > $dumpdir/${db}.sql.gz"
- else
- execstr="$DUMP -r $dumpdir/${db}.sql"
- fi
- fi
- debug "su $user -c \"$execstr\""
- if [ ! $test ]
- then
- output=`su $user -c "$execstr" 2>&1`
- code=$?
- if [ "$code" == "0" ]
- then
- debug $output
- info "Successfully finished dump of mysql database $db"
- else
- warning $output
- warning "Failed to dump mysql databases $db"
- fi
- fi
- done
-fi
-
-# clean up tmp config file
-if [ "$dbusername" != "" -a "$dbpassword" != "" ]
-then
- ## clean up tmp config file
- debug "rm $mycnf"
- rm $mycnf
- if [ -f "$tmpcnf" ]
- then
- debug "mv $tmpcnf $mycnf"
- mv $tmpcnf $mycnf
- fi
-fi
-
-return 0
diff --git a/handlers/pgsql.helper.in b/handlers/pgsql.helper.in
deleted file mode 100644
index 8024616..0000000
--- a/handlers/pgsql.helper.in
+++ /dev/null
@@ -1,107 +0,0 @@
-# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
-
-HELPERS="$HELPERS pgsql:postgresql_database_backup"
-
-do_pgsql_vserver() {
- choose_one_vserver "$pgsql_title"
- [ $? = 0 ] || return 1
- pgsql_vsname="vsname = $REPLY"
-}
-
-do_pgsql_databases() {
- REPLY=
- while [ -z "$REPLY" ]; do
- formBegin "$pgsql_title: databases"
- formItem "Database:"
- formItem "Database:"
- formItem "Database:"
- formItem "Database:"
- formItem "Database:"
- formItem "Database:"
- formItem "Database:"
- formItem "Database:"
- formItem "Database:"
- formItem "Database:"
- formDisplay
- [ $? = 0 ] || return 1
- pgsql_databases="databases = "
- for i in $REPLY; do
- [ -n "$i" ] && pgsql_databases="$pgsql_databases $i"
- done
- done
-}
-
-pgsql_wizard() {
-
- # constants
- pgsql_title="PostgreSQL action wizard"
-
- # backup the host system or a Vserver?
- choose_host_or_one_vserver "$pgsql_title"
- [ $? = 0 ] || return 1
- if [ $host_or_vservers == vservers ]; then
- do_pgsql_vserver
- [ $? = 0 ] || return 1
- fi
-
- # backupdir
- inputBox "$pgsql_title" "Directory where to store the backups:`[ -z \"$pgsql_vsname\" ] || echo \"\n(In respect to chosen vserver's root directory)\"`" "/var/backups/postgres"
- [ $? = 1 ] && return
- pgsql_backupdir="backupdir = $REPLY"
-
- # databases
- booleanBox "$pgsql_title" "Do you want to backup the whole cluster? If not, you'll be offered to choose the databases to backup."
- if [ $? = 0 ]; then
- pgsql_databases="databases = all"
- else
- do_pgsql_databases
- [ $? = 0 ] || return 1
- fi
-
- # compress
- booleanBox "$pgsql_title" "Do you want to compress the backups?"
- if [ $? = 0 ]; then
- pgsql_compress="compress = yes"
- else
- pgsql_compress="compress = no"
- fi
-
- # write config file
- get_next_filename $configdirectory/20.pgsql
- cat >> $next_filename <<EOF
-### backupninja PostgreSQL config file ###
-
-# vsname = <vserver> (no default)
-# what vserver to operate on, only used if vserver = yes in /etc/backupninja.conf
-# if you do not specify a vsname the host will be operated on
-# Note: if operating on a vserver, $VROOTDIR will be prepended to backupdir.
-EOF
- if [ $host_or_vservers == vservers ]; then
- echo -e "$pgsql_vsname\n" >> $next_filename
- fi
-
- cat >> $next_filename <<EOF
-# backupdir = <dir> (default: /var/backups/postgres)
-# where to dump the backups
-$pgsql_backupdir
-
-# databases = < all | db1 db2 db3 > (default = all)
-# which databases to backup. should either be the word 'all' or a
-# space separated list of database names.
-# Note: when using 'all', pg_dumpall is used instead of pg_dump, which means
-# that cluster-wide data (such as users and groups) are saved.
-$pgsql_databases
-
-# compress = < yes | no > (default = yes)
-# if yes, compress the pg_dump/pg_dumpall output.
-$pgsql_compress
-
-### You can also set the following variables in backupninja.conf:
-# PGSQLDUMP: pg_dump path (default: /usr/bin/pg_dump)
-# PGSQLDUMPALL: pg_dumpall path (default: /usr/bin/pg_dumpall)
-# PGSQLUSER: user running PostgreSQL (default: postgres)
-
-EOF
- chmod 600 $next_filename
-
-}
diff --git a/handlers/pgsql.in b/handlers/pgsql.in
deleted file mode 100644
index f334bf2..0000000
--- a/handlers/pgsql.in
+++ /dev/null
@@ -1,133 +0,0 @@
-# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
-#
-# PostgreSQL handler script for backupninja
-#
-
-getconf backupdir /var/backups/postgres
-getconf databases all
-getconf compress yes
-getconf vsname
-
-localhost=`hostname`
-
-# Decide if the handler should operate on a vserver or on the host.
-# In the former case, check that $vsname exists and is running.
-local usevserver=no
-local vroot
-if [ $vservers_are_available = yes ]; then
- if [ -n "$vsname" ]; then
- # does it exist ?
- if ! vservers_exist "$vsname" ; then
- fatal "The vserver given in vsname ($vsname) does not exist."
- fi
- # is it running ?
- vservers_running $vsname || fatal "The vserver $vsname is not running."
- # everything ok
- info "Using vserver '$vsname'."
- usevserver=yes
- vroot="$VROOTDIR/$vsname"
- else
- info "No vserver name specified, actions will be performed on the host."
- fi
-fi
-
-# Make sure that the system to backup has the needed executables
-if [ $usevserver = yes ]; then
- debug "Examining vserver '$vsname'."
- if [ "$databases" == "all" ]; then
- [ -x "$vroot`$VSERVER $vsname exec which $PGSQLDUMPALL`" ] || \
- fatal "Can't find $PGSQLDUMPALL in vserver $vsname."
- else
- [ -x "$vroot`$VSERVER $vsname exec which $PGSQLDUMP`" ] || \
- fatal "Can't find $PGSQLDUMP in vserver $vsname."
- fi
-else
- if [ "$databases" == "all" ]; then
- [ -x "`which $PGSQLDUMPALL`" ] || \
- fatal "Can't find $PGSQLDUMPALL."
- else
- [ -x "`which $PGSQLDUMP`" ] || \
- fatal "Can't find $PGSQLDUMP."
- fi
-fi
-
-# create backup dir, the vroot variable will be empty if no vsname was specified
-# and will proceed to operate on the host
-[ -d $vroot$backupdir ] || (debug "mkdir -p $vroot$backupdir"; mkdir -p $vroot$backupdir)
-[ -d $vroot$backupdir ] || fatal "Backup directory '$vroot$backupdir' does not exist, and could not be created."
-
-# give backup dir the good uid and permissions
-# (in respect to the vserver, if $usevserver = yes)
-if [ $usevserver = yes ]; then
- pguid=`$VSERVER $vsname exec getent passwd $PGSQLUSER | @AWK@ -F: '{print $3}'`
-else
- pguid=`getent passwd $PGSQLUSER | @AWK@ -F: '{print $3}'`
-fi
-[ -n "$pguid" ] || \
- fatal "No user called $PGSQLUSER`[ $usevserver = no ] || echo \" on vserver $vsname\"`."
-debug "chown $pguid $vroot$backupdir"
-chown $pguid $vroot$backupdir
-debug "chmod 700 $vroot$backupdir"
-chmod 700 $vroot$backupdir
-
-# if $databases = all, use pg_dumpall
-if [ "$databases" == "all" ]; then
- if [ $usevserver = yes ]; then
- if [ "$compress" == "yes" ]; then
- execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMPALL | $GZIP > $backupdir/${vsname}.sql.gz\""
- else
- execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMPALL > $backupdir/${vsname}.sql\""
- fi
- else
- if [ "$compress" == "yes" ]; then
- execstr="su - $PGSQLUSER -c \"$PGSQLDUMPALL | $GZIP > $backupdir/${localhost}-all.sql.gz\""
- else
- execstr="su - $PGSQLUSER -c \"$PGSQLDUMPALL > $backupdir/${localhost}-all.sql\""
- fi
- fi
- debug "$execstr"
- if [ ! $test ]; then
- output=`eval $execstr 2>&1`
- code=$?
- if [ "$code" == "0" ]; then
- debug $output
- info "Successfully finished dump of pgsql cluster"
- else
- warning $output
- warning "Failed to dump pgsql cluster"
- fi
- fi
-
-# else use pg_dump on each specified database
-else
- for db in $databases; do
- if [ $usevserver = yes ]; then
- if [ "$compress" == "yes" ]; then
- execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMP $db | $GZIP > $backupdir/${db}.sql.gz\""
- else
- execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMP $db | > $backupdir/${db}.sql\""
- fi
- else
- if [ "$compress" == "yes" ]; then
- execstr="su - $PGSQLUSER -c \"$PGSQLDUMP $db | $GZIP > $backupdir/${db}.sql.gz\""
- else
- execstr="su - $PGSQLUSER -c \"$PGSQLDUMP $db > $backupdir/${db}.sql\""
- fi
- fi
- debug "$execstr"
- if [ ! $test ]; then
- output=`eval $execstr 2>&1`
- code=$?
- if [ "$code" == "0" ]; then
- debug $output
- info "Successfully finished dump of pgsql database ${db}"
- else
- warning $output
- warning "Failed to dump pgsql database ${db}"
- fi
- fi
- done
-fi
-
-return 0
-
diff --git a/handlers/rdiff.helper.in b/handlers/rdiff.helper.in
deleted file mode 100644
index 1055280..0000000
--- a/handlers/rdiff.helper.in
+++ /dev/null
@@ -1,407 +0,0 @@
-# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
-
-HELPERS="$HELPERS rdiff:incremental_remote_filesystem_backup"
-
-declare -a rdiff_includes
-declare -a rdiff_excludes
-declare -a rdiff_vsincludes
-declare -a rdiff_vsexcludes
-
-# FUNCTIONS
-
-do_rdiff_host_includes() {
- set -o noglob
- # choose the files to backup
- REPLY=
- while [ -z "$REPLY" ]; do
- formBegin "$rdiff_title - host system: includes"
- for ((i=0; i < ${#rdiff_includes[@]} ; i++)); do
- formItem include ${rdiff_includes[$i]}
- done
- formItem include
- formItem include
- formItem include
- formDisplay
- [ $? = 0 ] || return
- unset rdiff_includes
- rdiff_includes=($REPLY)
- done
- set +o noglob
-}
-
-do_rdiff_vserver() {
- # choose the vservers to backup (into $selected_vservers)
- choose_one_or_more_vservers "$rdiff_title"
- [ $? = 0 ] || return 1
-
- set -o noglob
- # choose the files to backup
- REPLY=
-
- while [ -z "$REPLY" ]; do
- formBegin "$rdiff_title - vsincludes (backup these directories from every vserver)"
- [ -z "$rdiff_vsincludes" ] && rdiff_vsincludes="$rdiff_default_includes"
-
- for i in $rdiff_vsincludes; do
- formItem include "$i"
- done
- formItem include ""
- formItem include ""
- formItem include ""
- formDisplay
- [ $? = 0 ] || return 1
- rdiff_vsincludes=($REPLY)
- done
-
- set +o noglob
-}
-
-do_rdiff_excludes() {
- set -o noglob
- formBegin "$rdiff_title: excludes"
- for ((i=0; i < ${#rdiff_excludes[@]} ; i++))
- do
- formItem exclude ${rdiff_excludes[$i]}
- done
- formItem exclude
- formItem exclude
- formDisplay
- [ $? = 0 ] || return
- unset rdiff_excludes
- rdiff_excludes=($REPLY)
- set +o noglob
-}
-
-do_rdiff_src() {
- choose_host_or_vservers_or_both "$rdiff_title"
- [ $? = 0 ] || return 1
- case $host_or_vservers in
- 'host')
- do_rdiff_host_includes
- [ $? = 0 ] || return 1
- ;;
- 'vservers')
- do_rdiff_vserver
- [ $? = 0 ] || return 1
- ;;
- 'both')
- do_rdiff_host_includes
- [ $? = 0 ] || return 1
- do_rdiff_vserver
- [ $? = 0 ] || return 1
- ;;
- *)
- return 1
- ;;
- esac
- do_rdiff_excludes
- [ $? = 0 ] || return 1
- _src_done="(DONE)"
- setDefault dest
-}
-
-do_rdiff_dest() {
- declare -a tmp_array
-
- set -o noglob
- REPLY=
- while [ -z "$REPLY" -o -z "$rdiff_directory" -o -z "$rdiff_host" -o -z "$rdiff_user" ]
- do
- formBegin "$rdiff_title - destination: last three items are required"
- formItem "keep" "$rdiff_keep"
- formItem "dest_directory" "$rdiff_directory"
- formItem "dest_host" "$rdiff_host"
- formItem "dest_user" "$rdiff_user"
- formItem "dest_type" "$rdiff_type"
- formDisplay
- [ $? = 0 ] || return
- tmp_array=($REPLY)
- rdiff_keep=${tmp_array[0]}
- rdiff_directory=${tmp_array[1]}
- rdiff_host=${tmp_array[2]}
- rdiff_user=${tmp_array[3]}
- rdiff_type=${tmp_array[4]}
- done
- set +o noglob
-
- _dest_done="(DONE)"
- setDefault conn
-}
-
-do_rdiff_ssh_con() {
- local remote_status="ok"
-
- IFS=$' \t\n'
- if [ "$_dest_done" = "" ]; then
- msgBox "$rdiff_title: error" "You must first configure the destination."
- return
- elif [ "$rdiff_type" = "" ]; then
- msgBox "$rdiff_title: error" "You must first configure the destination backup type."
- return
- elif [ "$rdiff_user" = "" ]; then
- msgBox "$rdiff_title: error" "You must first configure the destination user."
- return
- elif [ "$rdiff_host" = "" ]; then
- msgBox "$rdiff_title: error" "You must first configure the destination host."
- return
- else
- booleanBox "$rdiff_title" "This step will create a ssh key for the local root user with no passphrase (if one does not already exist), and attempt to copy root's public ssh key to authorized_keys file of $rdiff_user@$rdiff_host. This will allow the local root to make unattended backups to $rdiff_user@$rdiff_host.\n\n\nAre you sure you want to continue?"
- [ $? = 0 ] || return
- fi
-
- if [ ! -f /root/.ssh/id_dsa.pub -a ! -f /root/.ssh/id_rsa.pub ]; then
- echo "Creating local root's ssh key"
- ssh-keygen -t dsa -f /root/.ssh/id_dsa -N ""
- echo "Done. hit return to continue"
- read
- fi
-
- ssh -o PreferredAuthentications=publickey $rdiff_host -l $rdiff_user "exit" 2> /dev/null
- if [ $? -ne 0 ]; then
- echo "Copying root's public ssh key to authorized_keys of $rdiff_user@$rdiff_host. When prompted, specify the password for user $rdiff_user@$rdiff_host."
- ssh-copy-id -i /root/.ssh/id_[rd]sa.pub $rdiff_user@$rdiff_host
- if [ $? -ne 0 ]; then
- echo "FAILED: Couldn't copy root's public ssh key to authorized_keys of $rdiff_user@$rdiff_host."
- ssh $rdiff_user@$rdiff_host 'test -w .ssh || test -w .'
- result=$?
- echo "Hit return to continue."
- read
- case $result in
- 0 ) msgBox "$rdiff_title: error" "Directories are writable: Probably just a typo the first time." ;;
- 1 ) msgBox "$rdiff_title: error" "Connected successfully to $rdiff_user@$rdiff_host, but unable to write. Check ownership and modes of ~$rdiff_user on $rdiff_host." ;;
- 255 ) msgBox "$rdiff_title: error" "Failed to connect to $rdiff_user@$rdiff_host. Check hostname, username, and password. Also, make sure sshd is running on the destination host." ;;
- * ) msgBox "$rdiff_title: error" "Unexpected error." ;;
- esac
- return
- else
- echo "Done. hit return to continue"
- read
- fi
- else
- echo "root@localhost is already in authorized_keys of $rdiff_user@$rdiff_host."
- echo "Hit return to continue."
- read
- fi
-
- # test to see if the remote rdiff backup directory exists and is writable
- echo "Testing to see if remote rdiff backup directory exists and is writable"
- ssh $rdiff_user@$rdiff_host "test -d ${rdiff_directory}"
- if [ $? = 0 ]; then
- ssh $rdiff_user@$rdiff_host "test -w $rdiff_directory"
- if [ $? != 0 ]; then
- msgBox "destination directory is not writable!" "The remote destination directory is not writable by the user you specified. Please fix the permissions on the directory and then try again."
- remote_status=failed
- fi
- else
- booleanBox "Remote directory does not exist" "The destination backup directory does not exist, do you want me to create it for you?"
- if [ $? = 0 ]; then
- ssh $rdiff_user@$rdiff_host "mkdir -p ${rdiff_directory}"
- result=$?
- case $result in
- 0) msgBox "$rdiff_title: success" "Creation of the remote destination directory was a success!";;
- 1) msgBox "$rdiff_title: error" "Connected successfully to $rdiff_user@$rdiff_host, but was unable to create the destination directory, check the directory permissions."
- remote_status=failed;;
- 255) msgBox "$rdiff_title: error" "Failed to connect to $rdiff_user@$rdiff_host. Check hostname, username, and password. Also, make sure sshd is running on the destination host."
- remote_status=failed;;
- *) msgBox "$rdiff_title: error" "Unexpected error."
- remote_status=failed;;
- esac
- fi
- fi
-
- if [ "$remote_status" = "ok" ]; then
- do_rdiff_con
- fi
-}
-
-do_rdiff_con() {
- echo "Checking for local install of rdiff-backup"
- require_packages rdiff-backup
-
- echo "Testing to make sure destination has rdiff-backup installed and is compatible."
- remote_result=`/usr/bin/rdiff-backup --test-server $rdiff_user@$rdiff_host::/ 2>&1 >&-`
- if [ $? -ne 0 ]; then
- echo $remote_result | grep -q "command not found"
- if [ $? -eq 0 ]; then
- if [ "$rdiff_user" = "root" ]; then
- booleanBox "install rdiff-backup?" "It seems like the remote machine does not have rdiff-backup installed, I can attempt to install rdiff-backup on the remote machine.\n\n\nDo you want me to attempt this now?"
- if [ $? = 0 ]; then
- ssh $rdiff_user@$rdiff_host 'apt-get install rdiff-backup'
- result=$?
- echo "Hit return to continue."
- read
- case $result in
- 0) msgBox "$rdiff_title: success" "Installation of rdiff-backup was a success!"
- do_rdiff_con;;
- 1) msgBox "$rdiff_title: error" "Connected successfully to $rdiff_user@$rdiff_host, but was unable to install the package for some reason.";;
- 255) msgBox "$rdiff_title: error" "Failed to connect to $rdiff_user@$rdiff_host. Check hostname, username, and password. Also, make sure sshd is running on the destination host.";;
- *) msgBox "$rdiff_title: error" "Unexpected error.";;
- esac
- return
- fi
- else
- booleanBox "install rdiff-backup" "Please install rdiff-backup on the remote machine, this cannot be done automatically, as the remote user in your configuration is not root. \n\nIf you have installed rdiff-backup on the remote machine and you are getting this error, then there is a version incompatibility between that version and the local version.\n\nPlease resolve this problem and then try connecting again.\n\n\n\nTry connecting again?"
- if [ $? = 0 ]; then
- do_rdiff_con
- else
- return
- fi
- fi
- else
- msgBox "incompatible versions of rdiff-backup" "It looks like rdiff-backup is installed on the remote machine, but it may be an incompatible version with the one installed locally, or something else is amiss.\n\nPlease resolve this problem and then try connecting again.\n\n\nTry connecting again?"
- if [ $? = 0 ]; then
- do_rdiff_con
- else
- return
- fi
- fi
- else
- echo "SUCCESS: Everything looks good!"
- echo "Hit return to continue."
- read
- fi
-
- _con_done="(DONE)"
- setDefault finish
-}
-
-do_rdiff_finish() {
- get_next_filename $configdirectory/90.rdiff
- cat > $next_filename <<EOF
-# options = --force
-# when = everyday at 02
-
-[source]
-type = local
-keep = $rdiff_keep
-
-# A few notes about includes and excludes:
-# 1. include, exclude and vsinclude statements support globbing with '*'
-# 2. Symlinks are not dereferenced. Moreover, an include line whose path
-# contains, at any level, a symlink to a directory, will only have the
-# symlink backed-up, not the target directory's content. Yes, you have to
-# dereference yourself the symlinks, or to use 'mount --bind' instead.
-# Example: let's say /home is a symlink to /mnt/crypt/home ; the following
-# line will only backup a "/home" symlink ; neither /home/user nor
-# /home/user/Mail will be backed-up :
-# include = /home/user/Mail
-# A workaround is to 'mount --bind /mnt/crypt/home /home' ; another one is to
-# write :
-# include = /mnt/crypt/home/user/Mail
-# 3. All the excludes come after all the includes. The order is not otherwise
-# taken into account.
-
-# files to include in the backup
-EOF
- ## includes ##
- if [ "$host_or_vservers" == host -o "$host_or_vservers" == both ]; then
- set -o noglob
- for ((i=0; i < ${#rdiff_includes[@]} ; i++)); do
- echo "include = ${rdiff_includes[$i]}" >> $next_filename
- done
- set +o noglob
- fi
-
- if [ "$host_or_vservers" == vservers -o "$host_or_vservers" == both ]; then
- cat >> $next_filename <<EOF
-#
-# If vservers = yes in /etc/backupninja.conf then the following variables can
-# be used:
-# vsnames = all | <vserver1> <vserver2> ... (default = all)
-# vsinclude = <path>
-# vsinclude = <path>
-# ...
-# Any path specified in vsinclude is added to the include list for each vserver
-# listed in vsnames (or all if vsnames = all, which is the default).
-#
-# For example, vsinclude = /home will backup the /home directory in every
-# vserver listed in vsnames. If you have 'vsnames = foo bar baz', this
-# vsinclude will add to the include list /vservers/foo/home, /vservers/bar/home
-# and /vservers/baz/home.
-# Vservers paths are derived from $VROOTDIR.
-
-EOF
- set -o noglob
- echo -e "vsnames = $selected_vservers\n" >> $next_filename
- for i in $rdiff_vsincludes; do
- echo "vsinclude = $i" >> $next_filename
- done
- set +o noglob
- fi
-
- ## excludes ##
- set -o noglob
- for ((i=0; i < ${#rdiff_excludes[@]} ; i++)); do
- echo exclude = ${rdiff_excludes[$i]} >> $next_filename
- done
- set +o noglob
- cat >> $next_filename <<EOF
-
-######################################################
-## destination section
-## (where the files are copied to)
-
-[dest]
-type = remote
-directory = $rdiff_directory
-host = $rdiff_host
-user = $rdiff_user
-EOF
-
- chmod 600 $next_filename
-}
-
-rdiff_main_menu() {
- while true; do
- srcitem="choose files to include & exclude $_src_done"
- destitem="configure backup destination $_dest_done"
- conitem="set up ssh keys and test remote connection $_con_done"
- advitem="edit advanced settings $_adv_done"
- menuBox "$rdiff_title" "choose a step:" \
- src "$srcitem" \
- dest "$destitem" \
- conn "$conitem" \
- finish "finish and create config file"
- [ $? = 0 ] || return
- result="$REPLY"
- case "$result" in
- "src") do_rdiff_src;;
- "dest") do_rdiff_dest;;
- "conn") do_rdiff_ssh_con;;
- "adv") do_rdiff_adv;;
- "finish")
- if [[ "$_con_done$_dest_done$_src_done" != "(DONE)(DONE)(DONE)" ]]; then
- msgBox "$rdiff_title" "You cannot create the configuration file until the other steps are completed."
- else
- do_rdiff_finish
- return
- fi
- ;;
- esac
- done
-}
-
-rdiff_wizard() {
-
- # Global variables
- rdiff_title="rdiff-backup action wizard"
- _src_done=
- _dest_done=
- _con_done=
- _adv_done=
- rdiff_keep=60D
- rdiff_directory=/backup/`hostname`
- rdiff_type=remote
- rdiff_user=
- rdiff_host=
-
- # Global variables whose '*' shall not be expanded
- set -o noglob
- rdiff_includes=(/var/spool/cron/crontabs /var/backups /etc /root /home /usr/local/*bin /var/lib/dpkg/status*)
- rdiff_excludes=(/home/*/.gnupg /home/*/.local/share/Trash /home/*/.Trash /home/*/.thumbnails /home/*/.beagle /home/*/.aMule /home/*/gtk-gnutella-downloads)
- rdiff_vsincludes=
- set +o noglob
-
- rdiff_main_menu
-}
-
diff --git a/handlers/rdiff.in b/handlers/rdiff.in
deleted file mode 100644
index 0f93429..0000000
--- a/handlers/rdiff.in
+++ /dev/null
@@ -1,257 +0,0 @@
-# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
-#
-# rdiff-backup handler script for backupninja
-# requires rdiff-backup
-#
-
-### FUNCTIONS ###
-
-function test_connection() {
- # given a user and host,
- # tests the connection.
- # if user or host is missing, returns 0
- # (ie, assume it's a local connection).
- if [ $# -lt 2 ]; then
- debug "(local is assumed to be a good connection)"
- return 0
- fi
- local user=$1
- local host=$2
- debug "ssh $sshoptions -o PasswordAuthentication=no $host -l $user 'echo -n 1'"
- local ret=`ssh $sshoptions -o PasswordAuthentication=no $host -l $user 'echo -n host is alive'`
- if echo $ret | grep "host is alive"; then
- debug "Connected to $host as $user successfully"
- else
- fatal "Can't connect to $host as $user."
- fi
-}
-
-function get_version() {
- # given no arguments, returns the local version.
- # given a user and host, returns the remote version.
- # if user or host is missing, returns the local version.
- if [ "$#" -lt 2 ]; then
- debug "$RDIFFBACKUP -V"
- echo `$RDIFFBACKUP -V`
- else
- local user=$1
- local host=$2
- debug "ssh $sshoptions $host -l $user '$RDIFFBACKUP -V'"
- echo `ssh $sshoptions $host -l $user "$RDIFFBACKUP -V | grep rdiff-backup"`
- fi
-}
-
-function check_consistency() {
- local section=$1
- local type=$2
- local user=$3
- local host=$4
- if [ "$type" == "local" ]; then
- if [ "$user" != "" ]; then
- warning "User should not be specified for local $section."
- fi
- if [ "$host" != "" ]; then
- warning "Host should not be specified for local $section."
- fi
- fi
- if [ "$type" == "remote" ]; then
- if [ "$user" == "" ]; then
- fatal "User must be specified for remote $section."
- fi
- if [ "host" == "" ]; then
- fatal "Host must be specifed for remote $section."
- fi
- fi
-}
-
-function check_cstream() {
- local cstream=$1
- if [ ! -x $cstream ]; then
- fatal "Can't find your cstream binary (trying: $cstream). If you use bwlimit you must have cstream installed."
- fi
-}
-
-### GET CONFIG ###
-
-getconf options
-getconf testconnect yes
-getconf nicelevel 0
-getconf bwlimit
-getconf ignore_version no
-
-setsection source
-getconf type; sourcetype=$type
-getconf user; sourceuser=$user
-getconf host; sourcehost=$host
-check_consistency "source" "$type" "$user" "$host"
-getconf label
-getconf keep 60
-getconf include
-getconf vsnames all
-getconf vsinclude
-getconf exclude
-
-setsection dest
-getconf directory; destdir=$directory
-# strip trailing /
-destdir=${destdir%/}
-getconf type; desttype=$type
-getconf user; destuser=$user
-getconf host; desthost=$host
-getconf sshoptions
-check_consistency "destination" "$type" "$user" "$host"
-
-if [ -n "$sshoptions" ] && echo $options | grep -qv "remote-schema"; then
- options="$options --remote-schema 'ssh -C $sshoptions %s rdiff-backup --server'"
-fi
-
-### CHECK CONFIG ###
-
-# If vservers are configured, check that the ones listed in $vsnames do exist.
-local usevserver=no
-if [ $vservers_are_available = yes ]; then
- if [ "$vsnames" = all ]; then
- vsnames="$found_vservers"
- else
- if ! vservers_exist "$vsnames" ; then
- fatal "At least one of the vservers listed in vsnames ($vsnames) does not exist."
- fi
- fi
- if [ -n "$vsinclude" ]; then
- info "Using vservers '$vsnames'"
- usevserver=yes
- fi
-else
- [ -z "$vsinclude" ] || warning 'vservers support disabled in backupninja.conf, vsincludes configuration lines will be ignored'
-fi
-
-# check the connection at the source and destination
-[ -n "$test" ] || test=0
-if [ "$testconnect" = "yes" ] || [ "${test}" -eq 1 ]; then
- test_connection $sourceuser $sourcehost
- test_connection $destuser $desthost
-fi
-
-if [ "$ignore_version" != "yes" ]; then
- # see that rdiff-backup has the same version at the source and destination
- sourceversion=`get_version $sourceuser $sourcehost`
- destversion=`get_version $destuser $desthost`
- if [ "$sourceversion" != "$destversion" ]; then
- fatal "rdiff-backup does not have the same version at the source and at the destination."
- fi
-fi
-
-# source specific checks
-case $sourcetype in
- remote ) execstr_sourcepart="$sourceuser@$sourcehost::/" ;;
- local ) execstr_sourcepart="/" ;;
- * ) fatal "sourcetype '$sourcetype' is neither local nor remote" ;;
-esac
-
-# destination specific checks
-[ "$destdir" != "" ] || fatal "Destination directory not set"
-case $desttype in
- remote ) execstr_destpart="$destuser@$desthost::$destdir/$label" ;;
- local ) execstr_destpart="$destdir/$label" ;;
- * ) fatal "desttype '$desttype' is neither local nor remote" ;;
-esac
-
-### REMOVE OLD BACKUPS ###
-
-if [ "$keep" != yes ]; then
-
- if [ "`echo $keep | tr -d 0-9`" == "" ]; then
- # add D if no other date unit is specified
- keep="${keep}D"
- fi
-
- removestr="$RDIFFBACKUP $options --force --remove-older-than $keep "
- if [ "$desttype" == "remote" ]; then
- removestr="${removestr}${destuser}@${desthost}::"
- fi
- removestr="${removestr}${destdir}/${label}";
-
- debug "$removestr"
- if [ $test = 0 ]; then
- output="`su -c "$removestr" 2>&1`"
- if [ $? = 0 ]; then
- debug $output
- info "Removing backups older than $keep days succeeded."
- else
- warning $output
- warning "Failed removing backups older than $keep."
- fi
- fi
-
-fi
-
-# Add cstream
-
-if [ ! -z $bwlimit ]; then
- check_cstream $CSTREAM;
- if [ "$desttype" = "remote" ]; then
- RDIFFBACKUP="$RDIFFBACKUP --remote-schema 'cstream -t $bwlimit | ssh %s \''rdiff-backup --server\'''"
- elif [ "$sourcetype" = "remote" ]; then
- RDIFFBACKUP="$RDIFFBACKUP --remote-schema 'ssh %s \''rdiff-backup --server\'' | cstream -t $bwlimit'"
- else
- fatal "You specified a bandwidth limit but neither your source nor destination types are remote."
- fi
-fi
-
-### EXECUTE ###
-
-execstr="$RDIFFBACKUP $options --print-statistics "
-
-set -o noglob
-
-symlinks_warning="Maybe you have mixed symlinks and '*' in this statement, which is not supported."
-
-# TODO: order the includes and excludes
-# excludes
-for i in $exclude; do
- str="${i//__star__/*}"
- execstr="${execstr}--exclude '$str' "
-done
-# includes
-for i in $include; do
- [ "$i" != "/" ] || fatal "Sorry, you cannot use 'include = /'"
- str="${i//__star__/*}"
- execstr="${execstr}--include '$str' "
-done
-
-# vsinclude
-if [ $usevserver = yes ]; then
- for vserver in $vsnames; do
- for vi in $vsinclude; do
- str="${vi//__star__/*}"
- str="$VROOTDIR/$vserver$str"
- if [ -n "$str" ]; then
- execstr="${execstr}--include '$str' "
- else
- warning "vsinclude statement '${vi//__star__/*}' will be ignored for VServer $vserver. $symlinks_warning"
- fi
- done
- done
-fi
-
-set +o noglob
-
-# exclude everything else
-[ "$include" != "" -o "$vsinclude" != "" ] && execstr="${execstr}--exclude '/*' "
-
-# include client-part and server-part
-execstr="${execstr}$execstr_sourcepart $execstr_destpart"
-
-debug "$execstr"
-if [ $test = 0 ]; then
- output=`nice -n $nicelevel su -c "$execstr" 2>&1`
- if [ $? = 0 ]; then
- debug $output
- info "Successfully finished backing up source $label"
- else
- warning $output
- warning "Failed backup up source $label"
- fi
-fi
-
-return 0
diff --git a/handlers/rsync.in b/handlers/rsync.in
deleted file mode 100644
index 9baa2f2..0000000
--- a/handlers/rsync.in
+++ /dev/null
@@ -1,350 +0,0 @@
-#
-# backupninja handler to do incremental backups using
-# rsync and hardlinks, based on
-#
-# http://www.mikerubel.org/computers/rsync_snapshots/
-#
-# feedback: rhatto at riseup.net | gpl
-# lot of enhancements grabbed from "rsnap" handler by paulv at bikkel.org
-#
-# Config file options
-# -------------------
-#
-# [general]
-# log = rsync log file
-# partition = partition where the backup lives
-# fscheck = set to 1 if fsck should run on $partition after the backup is made
-# read_only = set to 1 if $partition is mounted read-only
-# mountpoint = backup partition mountpoint or backup main folder
-# backupdir = folder relative do $mountpoint where the backup should be stored
-# days = number of backup increments (min = 5)
-# lockfile = lockfile to be kept during backup execution
-# nicelevel = rsync command nice level
-# enable_mv_timestamp_bug = set to "yes" if your system isnt handling timestamps correctly
-# tmp = temp folder
-#
-# [source]
-# from = local or remote
-# host = source hostname or ip, if remote backup
-# testconnect = when "yes", test the connection for a remote source before backup
-# include = include folder on backup
-# exclude = exclude folder on backup
-# ssh = ssh command line (remote only)
-# rsync = rsync program
-# rsync_options = rsync command options
-# exclude_vserver = vserver-name (valid only if vservers = yes on backupninja.conf)
-# numericids = when set to 1, use numeric ids instead of user/group mappings on rsync
-# compress = if set to 1, compress data on rsync (remote source only)
-# bandwidthlimit = set a badnwidth limit in kbps (remote source only)
-# remote_rsync = remote rsync program (remote source only)
-#
-# [services]
-# initscripts = absolute path where scripts are located
-# service = script name to be stoped at the begining of the backup and started at its end
-#
-# You can also specify some system comands if you don't want the default system values:
-#
-# [system]
-# rm = rm command
-# cp = cp command
-# touch = touch command
-# mv = mv command
-# fsck = fsck command
-#
-# You dont need to manually specify vservers using "include = /vservers".
-# They are automatically backuped if vserver is set to "yes" on you backupninja.conf.
-#
-
-# config file evaluation
-
-setsection system
-getconf rm rm
-getconf cp cp
-getconf touch touch
-getconf mv mv
-getconf fsck fsck
-
-setsection general
-getconf log /var/log/backup/rsync.log
-getconf partition
-getconf fscheck
-getconf read_only
-getconf mountpoint
-getconf backupdir
-getconf rotate
-getconf days
-getconf lockfile
-getconf nicelevel 0
-getconf enable_mv_timestamp_bug no
-getconf tmp /tmp
-
-setsection source
-getconf from local
-getconf testconnect no
-getconf rsync $RSYNC
-getconf rsync_options "-av --delete"
-getconf ssh ssh
-getconf user
-getconf host
-getconf include
-getconf exclude
-getconf exclude_vserver
-getconf numericids 0
-getconf compress 0
-getconf bandwidthlimit
-getconf remote_rsync rsync
-
-setsection services
-getconf initscripts
-getconf service
-
-# function definitions
-
-function rotate {
-
- if [[ "$2" < 4 ]]; then
- error "Rotate: minimum of 4 rotations"
- exit 1
- fi
-
- if [ -d $1.$2 ]; then
- $nice $mv /$1.$2 /$1.tmp
- fi
-
- for ((n=`echo "$2 - 1" | bc`; n >= 0; n--)); do
- if [ -d $1.$n ]; then
- dest=`echo "$n + 1" | bc`
- $nice $mv /$1.$n /$1.$dest
- $touch /$1.$dest
- fi
- done
-
- if [ -d $1.tmp ]; then
- $nice $mv /$1.tmp /$1.0
- fi
-
- if [ -d $1.1 ]; then
- $nice $cp -alf /$1.1/. /$1.0
- fi
-
-}
-
-function move_files {
-
- ref=$tmp/makesnapshot-mymv-$$;
- $touch -r $1 $ref;
- $mv $1 $2;
- $touch -r $ref $2;
- $rm $ref;
-
-}
-
-backupdir="$mountpoint/$backupdir"
-
-# does $backupdir exists?
-
-if [ ! -d "$backupdir" ]; then
- error "Backupdir $backupdir does not exist"
- exit 1
-fi
-
-# setup number of increments
-
-if [ -z "$days" ]; then
- keep="4"
-else
- keep="`echo $days - 1 | bc -l`"
-fi
-
-# lockfile setup
-
-if [ ! -z "$lockfile" ]; then
- $touch $lockfile || warning "Could not create lockfile $lockfile"
-fi
-
-# nicelevel setup
-
-if [ ! -z "$nicelevel" ]; then
- nice="nice -n $nicelevel"
-else
- nice=""
-fi
-
-# connection test
-
-if [ "$from" == "remote" ] && [ "$testconnect" == "yes" ]; then
- debug "$ssh -o PasswordAuthentication=no $user@$host 'echo -n 1'"
- result=`ssh -o PasswordAuthentication=no $user@$host 'echo -n 1'`
- if [ "$result" != "1" ]; then
- fatal "Can't connect to $host as $user."
- else
- debug "Connected to $srchost successfully"
- fi
-fi
-
-# rsync options for local sources
-
-if [ "$from" == "local" ]; then
-
- rsync_local_options="$rsync_options"
-
- if [ ! -z "$numericids" ]; then
- rsync_local_options="$rsync_local_options --numeric-ids "
- fi
-
-fi
-
-# rsync options for remote sources
-
-if [ "$from" == "remote" ]; then
-
- rsync_remote_options="$rsync_options --rsync-path=$remote_rsync"
-
- if [ "$compress" == "1" ]; then
- rsync_remote_options="$rsync_remote_options --compress"
- fi
-
- if [ ! -z "$bandwidthlimit" ]; then
- rsync_remote_options="$rsync_remote_options --bwlimit=$bandwidthlimit"
- fi
-
- if [ ! -z "$numericids" ]; then
- rsync_remote_options="$rsync_remote_options --numeric-ids"
- fi
-
-fi
-
-# set mv procedure
-
-if [ $enable_mv_timestamp_bug == "yes" ]; then
- mv=move_files
-fi
-
-# set excludes
-
-for path in $exclude; do
- EXCLUDES="$EXCLUDES --exclude=$path"
-done
-
-# stop services
-
-if [ ! -z "$service" ]; then
- for daemon in $service; do
- info "Stopping service $daemon..."
- $initscripts/$daemon stop
- done
-fi
-
-echo "Starting backup at `date`" >> $log
-
-# mount backup destination folder as read-write
-
-if [ "$read_only" == "1" ] || [ "$read_only" == "yes" ]; then
- if [ -d "$mountpoint" ]; then
- mount -o remount,rw $mountpoint
- if (($?)); then
- error "Could not mount $mountpoint"
- exit 1
- fi
- fi
-fi
-
-# add vservers to included folders
-
-if [ "$vservers_are_available" == "yes" ]; then
-
- # sane permission on backup
- mkdir -p $backupdir/$VROOTDIR
- chmod 000 $backupdir/$VROOTDIR
-
- for candidate in $found_vservers; do
- candidate="`basename $candidate`"
- found_excluded_vserver="0"
- for excluded_vserver in $exclude_vserver; do
- if [ "$excluded_vserver" == "$candidate" ]; then
- found_excluded_vserver="1"
- break
- fi
- done
- if [ "$found_excluded_vserver" == "0" ]; then
- include="$include $VROOTDIR/$candidate"
- fi
- done
-fi
-
-# the backup procedure
-
-for SECTION in $include; do
-
- section="`basename $SECTION`"
-
- if [ ! -d "$backupdir/$SECTION/$section.0" ]; then
- mkdir -p $backupdir/$SECTION/$section.0
- fi
-
- info "Rotating $backupdir/$SECTION/$section..."
- echo "Rotating $backupdir/$SECTION/$section..." >> $log
- rotate $backupdir/$SECTION/$section $keep
- info "Syncing $SECTION on $backupdir/$SECTION/$section.0..."
-
- if [ "$from" == "local" ]; then
- debug $rsync $rsync_local_options $EXCLUDES /$SECTION/ $backupdir/$SECTION/$section.0/
- $nice $rsync $rsync_local_options $EXCLUDES /$SECTION/ $backupdir/$SECTION/$section.0/ >> $log
- if [ "$?" != "0" ]; then
- warning "Rsync error when trying to transfer $SECTION"
- fi
- elif [ "$from" == "remote" ]; then
- if [ -z "$user" ] || [ -z "$host" ]; then
- error "Config file error: either user or host was not specified"
- exit 1
- else
- debug $nice $rsync $rsync_remote_options $EXCLUDES -e "$ssh" $user@$host:/$SECTION/ $backupdir/$SECTION/$section.0
- $nice $rsync $rsync_remote_options $EXCLUDES -e "$ssh" $user@$host:/$SECTION/ $backupdir/$SECTION/$section.0 >> $log
- if [ "$?" != "0" ]; then
- warning "Rsync error when trying to transfer $SECTION"
- fi
- fi
- else
- error "Invalid source $from"
- exit 1
- fi
-
- $touch $backupdir/$SECTION/$section.0
-
-done
-
-# remount backup destination as read-only
-
-if [ "$read_only" == "1" ] || [ "$read_only" == "yes" ]; then
- mount -o remount,ro $mountpoint
-fi
-
-# check partition for errors
-
-if [ "$fscheck" == "1" ] || [ "$fscheck" == "yes" ]; then
- umount $mountpoint
- if (($?)); then
- warning "Could not umount $mountpoint to run fsck"
- else
- $nice $fsck -v -y $partition >> $log
- mount $mountpoint
- fi
-fi
-
-# restart services
-
-if [ ! -z "$service" ]; then
- for daemon in $service; do
- info "Starting service $daemon..."
- $initscripts/$daemon start
- done
-fi
-
-# removes the lockfile
-
-if [ ! -z "$lockfile" ]; then
- $rm $lockfile || warning "Could not remove lockfile $lockfile"
-fi
-
-echo "Finnishing backup at `date`" >> $log
-
diff --git a/handlers/sh.in b/handlers/sh.in
deleted file mode 100644
index f9f1926..0000000
--- a/handlers/sh.in
+++ /dev/null
@@ -1,7 +0,0 @@
-# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
-#
-# shell script handler for backupninja
-# runs the file /etc/backup.d/scriptname.sh
-#
-
-[ $test ] || ( . $1 )
diff --git a/handlers/svn.in b/handlers/svn.in
deleted file mode 100644
index d19b0b8..0000000
--- a/handlers/svn.in
+++ /dev/null
@@ -1,77 +0,0 @@
-# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
-#
-# this handler will backup subversion repostitories.
-#
-
-getconf src /var/lib/svn
-getconf dest /var/backups/svn
-getconf tmp /var/backups/svn.tmp
-getconf HOTBACKUP "/usr/bin/svnadmin hotcopy"
-getconf vsname
-
-error=0
-
-# Decide if the handler should operate on a vserver or on the host.
-# In the former case, check that $vsname exists and is running.
-local usevserver=no
-local vroot
-if [ $vservers_are_available = yes ]; then
- if [ -n "$vsname" ]; then
- # does it exist ?
- if ! vservers_exist "$vsname" ; then
- fatal "The vserver given in vsname ($vsname) does not exist."
- fi
- # is it running ?
- vservers_running $vsname || fatal "The vserver $vsname is not running."
- # everything ok
- info "Using vserver '$vsname'."
- usevserver=yes
- vroot="$VROOTDIR/$vsname"
- else
- info "No vserver name specified, actions will be performed on the host."
- fi
-fi
-
-cd $vroot$src
-for repo in `find . -name svnserve.conf`
-do
- repo=`dirname $repo`
- repo=`dirname $repo`
-
- ret=`mkdir -p $vroot$tmp/$repo 2>&1`
- code=$?
- if [ "$ret" ]; then
- debug "$ret"
- fi
- if [ $code != 0 ]; then
- error "command failed mkdir -p $vroot$tmp/$repo"
- fi
-
- if [ $usevserver = yes ]
- then
- ret=`$VSERVER $vsname exec $HOTBACKUP $src/$repo $tmp/$repo 2>&1`
- else
- ret=`$HOTBACKUP $src/$repo $tmp/$repo 2>&1`
- fi
- code=$?
- if [ "$ret" ]; then
- debug "$ret"
- fi
- if [ $code != 0 ]; then
- error "command failed -- $HOTBACKUP $vroot$src/$repo $vroot$tmp/$repo"
- error=1
- fi
-done
-
-if [ $error -eq 1 ]; then
- echo "Error: because of earlier errors, we are leaving svn backups in $vroot$tmp instead of $vroot$dest"
-else
- if [ -d $vroot$dest -a -d $vroot$tmp ]; then
- rm -rf $vroot$dest
- fi
- if [ -d $vroot$tmp ]; then
- mv $vroot$tmp $vroot$dest
- fi
-fi
-
-exit 0
diff --git a/handlers/sys.helper.in b/handlers/sys.helper.in
deleted file mode 100644
index c5892a9..0000000
--- a/handlers/sys.helper.in
+++ /dev/null
@@ -1,53 +0,0 @@
-# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
-
-HELPERS="$HELPERS sys:general_hardware_and_system_info"
-
-sys_wizard() {
- require_packages hwinfo debconf-utils
- checkBox "new sys action" "check options" \
- "packages" "list of all installed packages." on \
- "partitions" "the partition table of all disks." on \
- "sfdisk" "use sfdisk to get partition information." on \
- "hardware" "detailed hardware information" on \
- "luksheaders" "Luks headers of all Luks partitions." off \
- "lvm" "LVM metadata for all volume groups." off
- [ $? = 1 ] && return;
- result="$REPLY"
- packages="packages = no"
- partitions="partitions = no"
- sfdisk="dosfdisk = no"
- hardware="hardware = no"
- luksheaders="luksheaders = no"
- lvm="lvm = no"
- for opt in $result; do
- case $opt in
- '"packages"') packages="packages = yes";;
- '"partitions"') partitions="partitions = yes";;
- '"sfdisk"') sfdisk="dosfdisk = yes";;
- '"hardware"') hardware="hardware = yes";;
- '"luksheaders"') luksheaders="luksheaders = yes";;
- '"lvm"') lvm="lvm = yes";;
- esac
- done
- get_next_filename $configdirectory/10.sys
- cat > $next_filename <<EOF
-$packages
-$partitions
-$sfdisk
-$hardware
-$luksheaders
-$lvm
-
-# packagesfile = /var/backups/dpkg-selections.txt
-# selectionsfile = /var/backups/debconfsel.txt
-# partitionsfile = /var/backups/partitions.__star__.txt
-# hardwarefile = /var/backups/hardware.txt
-# luksheadersfile = /var/backups/luksheader.__star__.bin
-
-# If vservers = yes in /etc/backupninja.conf then the following variables can
-# be used:
-# vsnames = all | <vserver1> <vserver2> ... (default = all)
-EOF
- chmod 600 $next_filename
-}
-
diff --git a/handlers/sys.in b/handlers/sys.in
deleted file mode 100755
index e6cb273..0000000
--- a/handlers/sys.in
+++ /dev/null
@@ -1,682 +0,0 @@
-# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
-#
-# this handler will save various reports of vital system information.
-# by default, all the reports are saved in /var/backups.
-#
-# (1) a capture of the debconf package selection states. This file
-# can be used to restore the answers to debconf questions for
-# packages that you will be installing through (2) below. To
-# do this, run: "debconf-set-selections < debconfsel.txt"
-#
-# (2) a list of all the packages installed and removed.
-# this file can be used to restore the state of installed packages
-# by running "dpkg --set-selections < dpkg-selections.txt and
-# then run "apt-get -u dselect-upgrade". If you have the
-# debconf-set-selections file from (1), you should restore those first.
-#
-# (3) the partition table of all disks.
-# this partition table can be used to format another disk of
-# the same size. this can be handy if using software raid and
-# you have a disk go bad. just replace the disk and partition it
-# by running "sfdisk /dev/sdb < partitions.sdb.txt"
-# (MAKE SURE YOU PARTITION THE CORRECT DISK!!!)
-#
-# (4) hardware information.
-# write to a text file the important things which hwinfo can gleen.
-#
-# (5) the Luks header of every Luks block device, if option luksheaders
-# is enabled.
-# in case you (have to) scramble such a Luks header (for some time),
-# and restore it later by running "dd if=luksheader.sda2.bin of=/dev/sda2"
-# (MAKE SURE YOU PASS THE CORRECT DEVICE AS of= !!!)
-#
-# (6) LVM metadata for every detected volume group, if "lvm = yes"
-#
-
-if [ -f /etc/debian_version ]
-then
- os=debian
- debug "Debian detected"
- osversion="/etc/debian_version"
-elif [ -f /etc/redhat-release ]
-then
- os=redhat
- debug "Redhat detected"
- osversion="/etc/redhat-release"
-else
- warning "Unknown OS detected!"
-fi
-
-getconf parentdir /var/backups
-getconf packages yes
-getconf dosfdisk yes
-getconf dohwinfo yes
-
-if [ ! -d $parentdir ]; then
- mkdir -p $parentdir
-fi
-
-if [ $os = "debian" ]
-then
- getconf packagesfile $parentdir/dpkg-selections.txt
- getconf packagemgr `which dpkg`
- getconf packagemgroptions ' --get-selections *'
- getconf selectionsfile $parentdir/debconfsel.txt
- getconf debconfgetselections `which debconf-get-selections`
-elif [ $os = "redhat" ]
-then
- getconf packagesfile $parentdir/rpmpackages.txt
- getconf packagemgr `which rpm`
- getconf packagemgroptions ' -qa '
-
- getconf SYSREPORT `which sysreport`
- getconf sysreport_options ' -norpm '
-else
- getconf packagesfile $parentdir/unknownOS.txt
-fi
-packagemgroptions="${packagemgroptions//__star__/*}"
-
-getconf partitions yes
-getconf partitionsfile $parentdir/partitions.__star__.txt
-
-getconf hardware yes
-getconf hardwarefile $parentdir/hardware.txt
-
-getconf sysreport yes
-getconf sysreportfile $parentdir/sysreport.txt
-
-getconf SFDISK `which sfdisk`
-getconf HWINFO `which hwinfo`
-getconf sfdisk_options ""
-getconf hwinfo_options ""
-
-getconf CRYPTSETUP `which cryptsetup`
-getconf DD `which dd`
-getconf luksheaders no
-getconf luksheadersfile $parentdir/luksheader.__star__.bin
-
-getconf VGS `which vgs`
-getconf VGCFGBACKUP `which vgcfgbackup`
-getconf lvm no
-
-getconf vsnames all
-
-# If vservers are configured, check that the ones listed in $vsnames are running.
-local usevserver=no
-if [ $vservers_are_available = yes ]; then
- if [ "$vsnames" = all ]; then
- vsnames="$found_vservers"
- fi
- if ! vservers_running "$vsnames" ; then
- fatal "At least one of the vservers listed in vsnames ($vsnames) is not running."
- fi
- info "Using vservers '$vsnames'"
- usevserver=yes
-fi
-
-## SANITY CHECKS #########################
-
-if [ "$luksheaders" == "yes" ]; then
- if [ ! -x "$DD" ]; then
- warning "can't find dd, skipping backup of Luks headers."
- luksheaders="no"
- fi
- if [ ! -x "$CRYPTSETUP" ]; then
- warning "can't find cryptsetup, skipping backup of Luks headers."
- luksheaders="no"
- fi
-fi
-
-if [ "$lvm" == "yes" ]; then
- if [ ! -x "$VGS" ]; then
- warning "can't find vgs, skipping backup of LVM metadata"
- lvm="no"
- fi
- if [ ! -x "$VGCFGBACKUP" ]; then
- warning "can't find vgcfgbackup, skipping backup of LVM metadata"
- lvm="no"
- fi
-fi
-
-## PACKAGES ##############################
-
-#
-# here we grab a list of the packages installed and removed.
-#
-
-if [ "$packages" == "yes" ]; then
-
- if [ $usevserver = yes ]; then
- info "vserver root directory set to: $VROOTDIR"
- for vserver in $vsnames; do
- info "examining vserver: $vserver"
- # is it running ?
- vservers_running $vserver
- if [ $? -ne 0 ]; then
- warning "The vserver $vserver is not running."
- continue
- fi
- # is $packagemgr available inside $vserver ?
- if [ ! -x "${VROOTDIR}/${vserver}${packagemgr}" ]; then
- warning "can't find $packagemgr in vserver $vserver, skipping installed packages report."
- else
- # don't expand * since it can be used in $packagemgroptions
- set -o noglob
- debug "$VSERVER $vserver exec $packagemgr $packagemgroptions > $VROOTDIR/$vserver$packagesfile"
- $VSERVER $vserver exec $packagemgr $packagemgroptions > $VROOTDIR/$vserver$packagesfile || fatal "can not save $packagemgr info to $packagesfile"
- set +o noglob
- fi
- # is $debconfgetselections available inside $vserver ?
- found=no
- # case #1: it is available on the host, is it available inside $vserver ?
- if [ -n "$debconfgetselections" ]; then
- [ -x "${VROOTDIR}/${vserver}${debconfgetselections}" ] && found=yes
- # case #2: it is not available on the host, is it available inside $vserver ?
- else
- [ -n "`$VSERVER $vserver exec which debconf-get-selections`" ] && found=yes
- fi
- if [ "$found" != yes ]; then
- warning "can't find debconf-get-selections in vserver $vserver, skipping package selection states. You may want to install the debconf-utils package."
- else
- debug "$VSERVER $vserver exec $debconfgetselections > $VROOTDIR/$vserver$selectionsfile"
- $VSERVER $vserver exec $debconfgetselections > $VROOTDIR/$vserver$selectionsfile || fatal "can not save debconf-get-selections info to $selectionsfile"
- fi
- unset found
- done
- fi
-
- # We want to perform this on the host as well
- if [ -z "$packagemgr" -o ! -x "$packagemgr" ]; then
- warning "can't find ${packagemgr}, skipping installed packages report."
- else
- # don't expand * since it can be used in $packagemgroptions
- set -o noglob
- debug "$packagemgr $packagemgroptions > $packagesfile"
- $packagemgr $packagemgroptions > $packagesfile || fatal "can not save $packagemgr info to $packagesfile"
- set +o noglob
- fi
- if [ -z "$debconfgetselections" ]; then
- warning "can't find debconf-get-selections, skipping package selection states. You might want to install the debconf-utils package."
- else
- debug "$debconfgetselections > $selectionsfile"
- $debconfgetselections > $selectionsfile || fatal "can not save $debconfgetselections info to $selectionsfile"
- fi
-fi
-
-## System report ##############################
-
-#
-# here we grab a bunch of system stuff for a report
-#
-
-export STATUS
-
-HASHES="#################################################################"
-DASHES="-----------------------------------------------------------------"
-
-cat /dev/null > $sysreportfile || fatal "can not write to $sysreportfile"
-
-
-catiffile () {
- echo $HASHES >> $sysreportfile
- echo "# $STATUS" >> $sysreportfile
- echo $HASHES >> $sysreportfile
- if [ -f $1 ]; then
- echo "file: $1" >> $sysreportfile
- echo $DASHES >> $sysreportfile
- cat $1 >> $sysreportfile 2>&1 || info "reading of $1 failed"
- fi
- if [ -d $1 ]; then
- echo "directory: $1" >> $sysreportfile
- echo $DASHES >> $sysreportfile
- for file in `find $1 -maxdepth 3 -noleaf -type f`
- do
- catiffile $file
- done
- fi
- echo $DASHES >> $sysreportfile
-}
-
-catifexec () {
- if [ -x $1 ]; then
- echo $HASHES >> $sysreportfile
- echo "# $STATUS" >> $sysreportfile
- echo $HASHES >> $sysreportfile
- $* >> $sysreportfile 2>&1 || info "executing of $1 failed"
- fi
-}
-
-
-STATUS="Determining $os version:"
-catiffile $osversion
-
-STATUS="Determinding your current hostname: "
-catifexec "/bin/hostname"
-
-STATUS="Getting the date:"
-catifexec "/bin/date"
-
-STATUS="Checking your systems current uptime and load average:"
-catifexec "/usr/bin/uptime"
-
-STATUS="Checking available memory:"
-catifexec "/usr/bin/free"
-
-STATUS="Checking free disk space:"
-catifexec "/bin/df" "-al"
-
-STATUS="Collecting what services run at what run level:"
-if [ $os = "redhat" ]; then
- catifexec "/sbin/chkconfig" "--list"
- STATUS="Collecting information about /etc/rc.d:"
- catiffile "/bin/ls /etc/rc.d/rc*.d/"
-
-elif [ $os = "debian" ]; then
- for level in 0 1 2 3 4 5 6 S; do
- echo "Level: $level" >> $sysreportfile
- for f in /etc/rc${level}.d/*; do
- # Remove /etc/Knn or Snn from beginning
- ff=$(echo $f | @SED@ 's_/etc/rc..d/[KS][0-9][0-9]__')
- if [ $f != $ff ]; then
- echo $ff >> $sysreportfile
- fi
- done
- echo "" >> $sysreportfile
- done
-fi
-
-STATUS="Getting bootloader information:"
-catifexec "/bin/ls" "-alR /boot"
-
-# This covers sparc, alpha, and intel (respectively)
-# updated for grub -mpg
-if [ -f /etc/silo.conf ]; then
- STATUS="Collecting information about the boot process (silo):"
- catiffile "/etc/silo.conf"
-fi
-if [ -f /etc/milo.conf ]; then
- STATUS="Collecting information about the boot process (milo):"
- catiffile "/etc/milo.conf"
-fi
-if [ -f /etc/lilo.conf ]; then
- STATUS="Collecting information about the boot process (lilo):"
- catiffile "/etc/lilo.conf"
- catifexec "/sbin/lilo" "-q"
-fi
-if [ -d /boot/grub -a -f /boot/grub/grub.conf -a -f /boot/grub/device.map ]; then
- STATUS="Collecting information about the boot process (grub.conf):"
- catiffile "/boot/grub/grub.conf"
- STATUS="Collecting information about the boot process (grub.map):"
- catiffile "/boot/grub/device.map"
-fi
-if [ -f /etc/cluster.conf -o -f /etc/cluster.xml ] ; then
- STATUS="Gathering information on cluster setup"
- # 2.1 AS
- if [ -f /etc/cluster.conf ] ; then
- catiffile "/etc/cluster.conf"
- fi
- # Taroon
- if [ -f /etc/cluster.xml ] ; then
- catiffile "/etc/cluster.xml"
- fi
-fi
-
-STATUS="Gathering sysctl information (sysctl -a):"
-catiffile "sysctl -a 2>/dev/null"
-STATUS="Gathering sysctl information (/etc/sysctl.conf):"
-catiffile "/etc/sysctl.conf"
-
-STATUS="Gathering IP information (/sbin/ifconfig):"
-catifexec "/sbin/ifconfig" "-a"
-
-STATUS="Gathering additional IP information (/bin/ip addr list):"
-catifexec "/bin/ip" "addr list"
-
-STATUS="Checking network routes:"
-catifexec "/sbin/route" "-n"
-
-STATUS="Collecting Name Service Switch config information:"
-catiffile "/etc/nsswitch.conf"
-
-STATUS="Collecting information about system authentication (pam):"
-catiffile "/etc/pam.conf"
-catiffile "/etc/pam.d"
-
-echo
-echo "Getting information about the kernel."
-echo
-STATUS="Getting kernel version:"
-catifexec "/bin/uname" "-a"
-STATUS="Checking module information:"
-catifexec "/sbin/lsmod"
-for x in $(/sbin/lsmod | /bin/cut -f1 -d" " 2>/dev/null | /bin/grep -v Module 2>/dev/null
-) ; do
- STATUS="Checking module information $x:"
- catifexec "/sbin/modinfo" "$x"
-done
-
-STATUS="Gathering information about your filesystems:"
-catiffile "/proc/filesystems"
-
-STATUS="Gathering information about your system stat:"
-catiffile "/proc/stat"
-
-STATUS="Gathering information about your partitions:"
-catiffile "/proc/partitions"
-
-STATUS="Gathering information about your ksyms:"
-catiffile "/proc/kallsyms"
-
-STATUS="Gathering information about slabinfo:"
-catiffile "/proc/slabinfo"
-
-# Added support to cover for the new modules.conf layout in Red Hat 7
-STATUS="Collecting information regarding kernel modules"
-VER=`uname -r`
-catiffile "/lib/modules/$VER/modules.dep"
-if [ -f /etc/conf.modules ]; then
- STATUS="Collecting information regarding kernel modules (conf.modules)"
- catiffile "/etc/conf.modules"
-fi
-if [ -f /etc/modules.conf ]; then
- STATUS="Collecting information regarding kernel modules (modules.conf)"
- catiffile "/etc/modules.conf"
-fi
-if [ -f /etc/modprobe.conf ]; then
- STATUS="Collecting information regarding kernel modules (modeprobe.conf)"
- catiffile "/etc/modprobe.conf"
-fi
-
-# dkms status
-if [ -x /usr/sbin/dkms ] ; then
- STATUS="Gathering current status of modules, versions and kernels (dkms):"
- catifexec "/usr/sbin/dkms" "status"
-fi
-
-if [ -f /etc/sysconfig/isdncard ] ; then
- STATUS="Gathering information about ISDN:"
- catiffile "/etc/sysconfig/isdncard"
-fi
-
-STATUS="Collecting information from the proc directory:"
-catiffile "/proc/pci"
-
-STATUS="Getting kernel command line"
-catiffile "/proc/cmdline"
-
-STATUS="Gathering information about your CPU:"
-catiffile "/proc/cpuinfo"
-
-STATUS="Gathering information about your Ram:"
-catiffile "/proc/meminfo"
-
-STATUS="Gathering information about your ioports:"
-catiffile "/proc/ioports"
-
-STATUS="Gathering information about your interrupts:"
-catiffile "/proc/interrupts"
-
-STATUS="Gathering information about your scsi devices:"
-catiffile "/proc/scsi"
-
-STATUS="Gathering information about your dma:"
-catiffile "/proc/dma"
-
-STATUS="Gathering information about your devices (/proc/devices):"
-catiffile "/proc/devices"
-
-STATUS="Gathering information about your rtc:"
-catiffile "/proc/rtc"
-
-STATUS="Gathering information about your ide drivers:"
-catiffile "/proc/ide"
-
-STATUS="Gathering information about your bus:"
-catifexec "/usr/bin/lspci"
-catiffile "/proc/bus"
-
-echo
-echo "Getting disk and filesystem information."
-echo
-
-STATUS="Collecting information from /etc/fstab:"
-catiffile "/etc/fstab"
-
-STATUS="Collecting disk partition information:"
-catifexec "/sbin/fdisk" "-l"
-
-STATUS="Checking mounted file systems (mount) "
-catifexec "/bin/mount"
-
-STATUS="Checking mounted file systems (/proc/mounts)"
-catiffile "/proc/mounts"
-
-STATUS="Collecting Software RAID information (/proc/mdstat)"
-catiffile "/proc/mdstat"
-
-STATUS="Collecting Software RAID information (/etc/raidtab)"
-catiffile "/etc/raidtab"
-
-STATUS="Collecting Software RAID information (/etc/mdadm.conf)"
-catiffile "/etc/mdadm.conf"
-
-STATUS="Collecting Software RAID information (/sbin/mdadm -Q)"
-catifexec "/sbin/mdadm" "-Q" "--detail" '/dev/md?*'
-
-STATUS="Collecting Automount information (auto.master)"
-catiffile "/etc/auto.master"
-
-STATUS="Collecting Automount information (auto.misc)"
-catiffile "/etc/auto.misc"
-
-STATUS="Collecting Automount information (auto.net)"
-catiffile "/etc/auto.net"
-
-STATUS="Collecting LVM information:"
-if [ $os = "redhat" ]; then
- catifexec "/usr/sbin/vgdisplay" "-vv"
-elif [ $os = "debian" ]; then
- catifexec "/sbin/vgdisplay" "-vv"
-fi
-
-STATUS="Collecting device-mapper (dm) information:"
-catifexec '/sbin/dmsetup' 'info'
-
-STATUS="Collecting SCSI Tape information (/etc/stinit.def)"
-catiffile "/etc/stinit.def"
-
-if [ -x /sbin/lsusb ] ; then
- STATUS="Collecting USB devices list (lsusb):"
- catifexec "/sbin/lsusb"
-fi
-
-if [ -x /usr/bin/lshal ] ; then
- STATUS="Collecting global devices list (lshal):"
- catifexec "/usr/bin/lshal"
-fi
-
-
-STATUS="Gathering information on SELinux setup"
-catifexec "/usr/bin/selinuxconfig"
-catifexec "/usr/sbin/sestatus"
-if [ $os = "redhat" ]; then
- catifexec "rpm" "-q -V selinux-policy-targeted"
- catifexec "rpm" "-q -V selinux-policy-strict"
-fi
-
-if [ $usevserver = yes ]; then
- STATUS="Gathering vserver information"
- catiffile "/proc/virtual"
-fi
-
-if [ "$partitions" == "yes" ]; then
- if [ "$dosfdisk" == "yes" ]; then
- if [ ! -x "$SFDISK" ]; then
- warning "can't find sfdisk, skipping sfdisk report."
- partitions="no"
- fi
- fi
- if [ "$dohwinfo" == "yes" ]; then
- if [ ! -x "$HWINFO" ]; then
- warning "can't find hwinfo, skipping partition report."
- partitions="no"
- fi
- fi
-fi
-
-if [ "$hardware" == "yes" ]; then
- if [ ! -x "$HWINFO" ]; then
- warning "can't find hwinfo, skipping hardware report."
- hardware="no"
- fi
-fi
-
-## HARDWARE #############################
-
-#
-# here we use hwinfo to dump a table listing all the
-# information we can find on the hardware of this machine
-#
-
-if [ "$hardware" == "yes" ]; then
- if [ "dohwinfo" == "yes" ]; then
- if [ -f $hardwarefile ]; then
- rm $hardwarefile
- fi
- touch $hardwarefile
- echo -e "\n\n====================== summary ======================\n" >> $hardwarefile
- debug "$HWINFO --short --cpu --network --disk --pci >> $hardwarefile"
- $HWINFO --short --cpu --network --disk --pci >> $hardwarefile
- for flag in cpu network bios pci; do
- echo -e "\n\n====================== $flag ======================\n" >> $hardwarefile
- $HWINFO --$flag >> $hardwarefile
- done
- fi
-fi
-
-## PARTITIONS #############################
-
-# here we use sfdisk to dump a listing of all the partitions.
-# these files can be used to directly partition a disk of the same size.
-
-if [ "$partitions" == "yes" ]; then
- if [ "$dosfdisk" == "yes" ]; then
- devices=`LC_ALL=C $SFDISK -l 2>/dev/null | grep "^Disk /dev" | @AWK@ '{print $2}' | cut -d: -f1`
- if [ "$devices" == "" ]; then
- warning "No harddisks found"
- fi
- for dev in $devices; do
- debug "$SFDISK will try to backup partition tables for device $dev"
- [ -b $dev ] || continue
- label=${dev#/dev/}
- label=${label//\//-}
- outputfile=${partitionsfile//__star__/$label}
- debug "$SFDISK $sfdisk_options -d $dev > $outputfile 2>/dev/null"
- $SFDISK $sfdisk_options -d $dev > $outputfile 2>/dev/null
- if [ $? -ne 0 ]; then
- warning "The partition table for $dev could not be saved."
- fi
- done
- fi
- if [ "$dohwinfo" == "yes" ]; then
- debug "Using $HWINFO to get all available disk information"
- echo -e "\n\n====================== $disk ======================\n" >> $hardwarefile
- $HWINFO --disk >> $hardwarefile
- fi
-fi
-
-if [ "$luksheaders" == "yes" ]; then
- devices=`LC_ALL=C $SFDISK -l 2>/dev/null | grep "^Disk /dev" | @AWK@ '{print $2}' | cut -d: -f1`
- [ -n "$devices" ] || warning "No block device found"
- targetdevices=""
- for dev in $devices; do
- [ -b $dev ] || continue
- debug "$CRYPTSETUP isLuks $dev"
- $CRYPTSETUP isLuks $dev
- [ $? -eq 0 ] && targetdevices="$targetdevices $dev"
- done
- for dev in $targetdevices; do
- label=${dev#/dev/}
- label=${label//\//-}
- outputfile=${luksheadersfile//__star__/$label}
- # the following sizes are expressed in terms of 512-byte sectors
- debug "Let us find out the Luks header size for $dev"
- debug "$CRYPTSETUP luksDump \"$dev\" | grep '^Payload offset:' | @AWK@ '{print $3}'"
- headersize=`$CRYPTSETUP luksDump "$dev" | grep '^Payload offset:' | @AWK@ '{print $3}'`
- if [ $? -ne 0 ]; then
- warning "Could not compute the size of Luks header, skipping device $dev"
- continue
- elif [ -z "$headersize" -o -n "`echo \"$headersize\" | sed 's/[0-9]*//g'`" ]; then
- warning "The computed size of Luks header is not an integer, skipping device $dev"
- continue
- fi
- debug "Let us backup the Luks header of device $dev"
- debug "$DD if=\"${dev}\" of=\"${outputfile}\" bs=512 count=\"${headersize}\""
- output=`$DD if="${dev}" of="${outputfile}" bs=512 count="${headersize}" 2>&1`
- exit_code=$?
- if [ $exit_code -eq 0 ]; then
- debug $output
- info "The Luks header of $dev was saved to $outputfile."
- else
- debug $output
- fatal "The Luks header of $dev could not be saved."
- fi
- done
-fi
-
-## LVM ####################################
-
-# returns 0 on success, 1 on error, 2 if not tried
-# outputs error message if error, reason if not tried
-function doLvmBackup () {
- local lvmdir="$1"
- if [ ! -d "$lvmdir" ]; then
- if ! mkdir "$lvmdir"; then
- echo "could not create $lvmdir"
- return 2
- else
- info "successfully created $lvmdir"
- fi
- fi
- if [ ! -w "$lvmdir" ]; then
- echo "can not write to directory $lvmdir"
- return 2
- fi
- debug "Let's try to gather the list of LVM volume groups"
- debug "$VGS --options vg_name --noheadings | @SED@ 's/^[ ]*//' | @SED@ 's/[ ]*$//' | tr '\n' ' '"
- vgs=`$VGS --options vg_name --noheadings | @SED@ 's/^[ ]*//' | @SED@ 's/[ ]*$//' | tr '\n' ' '`
- debug "Let's try to backup LVM metadata for detected volume groups: $vgs"
- debug "$VGCFGBACKUP --file \"${lvmdir}\"/\'%s\' $vgs"
- output=`$VGCFGBACKUP --file "${lvmdir}"/'%s' $vgs`
- exit_code=$?
- debug $output
- case $exit_code in
- 0)
- info "LVM metadata was saved to $lvmdir for volume groups: $vgs"
- return 0
- ;;
- *)
- echo "LVM metadata could not be saved for at least one of these volume groups: $vgs"
- return 1
- ;;
- esac
-}
-
-if [ "$lvm" == "yes" ]; then
- output=`doLvmBackup "${parentdir}/lvm"`
- exit_code=$?
- case $exit_code in
- 0) # success. info message has already been displayed
- true
- ;;
- 1) # error
- fatal "$output"
- ;;
- 2) # could not even try
- fatal "LVM metadata backup was not tried: $output"
- ;;
- *) # should never happen
- fatal "Unhandled error ($exit_code) while trying to backup LVM metadata, please report a bug"
- ;;
- esac
-fi
diff --git a/handlers/tar.helper.in b/handlers/tar.helper.in
deleted file mode 100644
index cc9a89b..0000000
--- a/handlers/tar.helper.in
+++ /dev/null
@@ -1,94 +0,0 @@
-# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
-
-HELPERS="$HELPERS tar:tar_backup"
-
-tar_wizard() {
- tar_title="Tar action wizard"
-
- backupname=`hostname --fqdn`
-
- inputBox "$tar_title" "When to run this action?" "everyday at 01"
- [ $? = 1 ] && return
- tar_when_run="when = $REPLY"
-
- inputBox "$tar_title" "\"Name\" of backups" "$backupname"
- [ $? = 1 ] && return
- tar_backupname="backupname = $REPLY"
- backupname="$REPLY"
-
- inputBox "$tar_title" "Directory where to store the backups" "/net/backups/$backupname"
- [ $? = 1 ] && return
- tar_backupdir="backupdir = $REPLY"
-
- radioBox "$tar_title" "Compression" \
- "none" "do not filter trough" off \
- "compress" "filter trough compress" off \
- "gzip" "filter trough gzip" off \
- "bzip" "filter trough bzip" on
- [ $? = 1 ] && return;
- result="$REPLY"
- tar_compress="compress = $REPLY "
-
- REPLY=
- while [ -z "$REPLY" ]; do
- formBegin "$tar_title: Includes"
- formItem "Include:" /etc
- formItem "Include:" /home
- formItem "Include:" /usr/local
- formItem "Include:"
- formItem "Include:"
- formItem "Include:"
- formItem "Include:"
- formItem "Include:"
- formItem "Include:"
- formItem "Include:"
- formItem "Include:"
- formDisplay
- [ $? = 0 ] || return 1
- tar_includes="includes = "
- for i in $REPLY; do
- [ -n "$i" ] && tar_includes="$tar_includes $i"
- done
- done
-
- REPLY=
- while [ -z "$REPLY" ]; do
- formBegin "$tar_title: Excludes"
- formItem "Exclude:" /tmp
- formItem "Exclude:" /proc
- formItem "Exclude:" /sys
- formItem "Exclude:" /dev
- formItem "Exclude:" /srv
- formItem "Exclude:" /media
- formItem "Exclude:" /misc
- formItem "Exclude:" /net
- formItem "Exclude:" /selinux
- formItem "Exclude:"
- formItem "Exclude:"
- formDisplay
- [ $? = 0 ] || return 1
- tar_excludes="excludes = "
- for i in $REPLY; do
- [ -n "$i" ] && tar_excludes="$tar_excludes $i"
- done
- done
-
-# Save the config
- get_next_filename $configdirectory/10.tar
- cat > $next_filename <<EOF
-$tar_when_run
-$tar_backupname
-$tar_backupdir
-$tar_compress
-$tar_includes
-$tar_excludes
-
-# tar binary - have to be GNU tar
-#TAR=/bin/tar
-#DATE /bin/date
-#DATEFORMAT "%Y.%m.%d-%H%M"
-
-EOF
- chmod 600 $next_filename
-}
-
diff --git a/handlers/tar.in b/handlers/tar.in
deleted file mode 100644
index 7f0d147..0000000
--- a/handlers/tar.in
+++ /dev/null
@@ -1,79 +0,0 @@
-# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
-#
-# tar handler script for backupninja
-
-getconf backupname `hostname --fqdn`
-getconf backupdir /var/backups/`hostname --fqdn`
-getconf compress bzip
-getconf includes "/etc /home /usr/local"
-getconf excludes "/tmp /proc /dev /sys /net /misc /media /srv /selinux"
-
-getconf TAR `which tar`
-getconf EXTENSION tar
-getconf DATE `which date`
-getconf DATEFORMAT "%Y.%m.%d-%H%M"
-
-# See if vservers are configured
-if [ "$vservers" = "yes" ]
-then
- warning "vservers enabled, but tar does not support it!"
-fi
-
-if [ ! -d "$backupdir" ]
-then
- mkdir -p "$backupdir" || fatal "Can not make directory $backupdir"
-fi
-
-if [ ! -w "$backupdir" ]
-then
- fatal "Directory $backupdir is not writable"
-fi
-
-## DO IT #################################################
-#
-# here we grab a list of the packages installed and removed.
-#
-
-case $compress in
- "compress")
- compress_option="-Z"
- EXTENSION="tar.compress"
- ;;
- "gzip")
- compress_option="-z"
- EXTENSION="tgz"
- ;;
- "bzip")
- compress_option="-j"
- EXTENSION="tar.bz2"
- ;;
- "none")
- compress_option=""
- ;;
- *)
- warning "Unknown compress filter ($tar_compress)"
- compress_option=""
- EXTENSION="tgz"
- ;;
-esac
-
-exclude_options=""
-for i in $excludes
-do
- exclude_options="$exclude_options --exclude $i"
-done
-
-debug "Running backup: " $TAR -c -p -v $compress_option $exclude_options \
- -f "$backupdir/$backupname-"`$DATE "+$DATEFORMAT"`".$EXTENSION" \
- $includes
-
-$TAR -c -p -v $compress_option $exclude_options \
- -f "$backupdir/$backupname-"`$DATE "+$DATEFORMAT"`".$EXTENSION" \
- $includes \
- > "$backupdir/$backupname-"`$DATE "+$DATEFORMAT"`.list \
- 2> "$backupdir/$backupname-"`$DATE "+$DATEFORMAT"`.err
-
-[ $? -ne 0 ] && fatal "Tar backup failed"
-
-
-
diff --git a/handlers/trac.in b/handlers/trac.in
deleted file mode 100644
index a4b7bdf..0000000
--- a/handlers/trac.in
+++ /dev/null
@@ -1,52 +0,0 @@
-# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*-
-#
-# this handler will backup trac environments (based on the svn handler)
-#
-# http://trac.edgewall.com/
-#
-
-getconf src /var/lib/trac
-getconf dest /var/backups/trac
-getconf tmp /var/backups/trac.tmp
-
-cd $src
-for repo in `find . -name VERSION`
-do
-
- repo=`dirname $repo`
- if [ "$repo" == "." ]
- then
- repo=""
- fi
-
- # Just make the parent directory for $tmp/$repo
- parentdir=`dirname $tmp/$repo`
- ret=`mkdir -p $parentdir 2>&1`
- code=$?
- if [ "$ret" ]; then
- debug "$ret"
- fi
- if [ $code != 0 ]; then
- error "command failed mkdir -p $parentdir"
- fi
-
- ret=`trac-admin $src/$repo hotcopy $tmp/$repo 2>&1`
- code=$?
- if [ "$ret" ]; then
- debug "$ret"
- fi
- if [ $code != 0 ]; then
- error "command failed -- trac-admin $src/$repo hotcopy $tmp/$repo"
- fi
-done
-
-if [ -d $dest -a -d $tmp ]; then
- rm -rf $dest
-fi
-if [ -d $tmp ]; then
- mv $tmp $dest
-fi
-
-exit 0
-
-# vim: filetype=sh
diff --git a/handlers/wget b/handlers/wget
deleted file mode 100644
index 51054ea..0000000
--- a/handlers/wget
+++ /dev/null
@@ -1,220 +0,0 @@
-#
-# backupninja handler to do incremental backups using
-# wget and hardlinks, based on rsync handler
-#
-# feedback: rhatto at riseup.net | gpl
-#
-# Config file options
-# -------------------
-#
-# [general]
-# log = wget log file
-# partition = partition where the backup lives
-# fscheck = set to 1 if fsck should run on $partition after the backup is made
-# read_only = set to 1 if $partition is mounted read-only
-# mountpoint = backup partition mountpoint or backup main folder
-# backupdir = folder relative do $mountpoint where the backup should be stored
-# days = number of backup increments (min = 5)
-# lockfile = lockfile to be kept during backup execution
-# nicelevel = wget command nice level
-# enable_mv_timestamp_bug = set to "yes" if your system isnt handling timestamps correctly
-# tmp = temp folder
-#
-# [source]
-# wget = wget program
-# wget_options = wget command options
-# url = remote data url
-# bandwidthlimit = set a badnwidth limit in kbps (remote source only)
-#
-# [destination]
-# folder = local folder
-#
-# You can also specify some system comands if you don't want the default system values:
-#
-# [system]
-# rm = rm command
-# cp = cp command
-# touch = touch command
-# mv = mv command
-# fsck = fsck command
-#
-# TODO: Daily, weekly and monthly snapshot rotation (like the one present on maildir handler).
-#
-
-# config file evaluation
-
-setsection system
-getconf rm rm
-getconf cp cp
-getconf touch touch
-getconf mv mv
-getconf fsck fsck
-
-setsection general
-getconf log /var/log/backup/wget.log
-getconf partition
-getconf fscheck
-getconf read_only
-getconf mountpoint
-getconf backupdir
-getconf rotate
-getconf days
-getconf lockfile
-getconf nicelevel 0
-getconf enable_mv_timestamp_bug no
-getconf tmp /tmp
-
-setsection source
-getconf wget wget
-getconf wget_options
-getconf url
-getconf bandwidthlimit
-
-setsection destination
-getconf folder
-
-# function definitions
-
-function rotate {
-
- if [[ "$2" < 4 ]]; then
- error "Rotate: minimum of 4 rotations"
- exit 1
- fi
-
- if [ -d $1.$2 ]; then
- $nice $mv /$1.$2 /$1.tmp
- fi
-
- for ((n=`echo "$2 - 1" | bc`; n >= 0; n--)); do
- if [ -d $1.$n ]; then
- dest=`echo "$n + 1" | bc`
- $nice $mv /$1.$n /$1.$dest
- $touch /$1.$dest
- fi
- done
-
- if [ -d $1.tmp ]; then
- $nice $mv /$1.tmp /$1.0
- fi
-
- if [ -d $1.1 ]; then
- $nice $cp -alf /$1.1/. /$1.0
- fi
-
-}
-
-function move_files {
-
- ref=$tmp/makesnapshot-mymv-$$;
- $touch -r $1 $ref;
- $mv $1 $2;
- $touch -r $ref $2;
- $rm $ref;
-
-}
-
-backupdir="$mountpoint/$backupdir"
-
-# does $backupdir exists?
-
-if [ ! -d "$backupdir" ]; then
- error "Backupdir $backupdir does not exist"
- exit 1
-fi
-
-# setup number of increments
-
-if [ -z "$days" ]; then
- keep="4"
-else
- keep="`echo $days - 1 | bc -l`"
-fi
-
-# lockfile setup
-
-if [ ! -z "$lockfile" ]; then
- $touch $lockfile || warning "Could not create lockfile $lockfile"
-fi
-
-# nicelevel setup
-
-if [ ! -z "$nicelevel" ]; then
- nice="nice -n $nicelevel"
-else
- nice=""
-fi
-
-# set mv procedure
-
-if [ $enable_mv_timestamp_bug == "yes" ]; then
- mv=move_files
-fi
-
-# set excludes
-
-for path in $exclude; do
- EXCLUDES="$EXCLUDES --exclude=$path"
-done
-
-echo "Starting backup at `date`" >> $log
-
-# mount backup destination folder as read-write
-
-if [ "$read_only" == "1" ] || [ "$read_only" == "yes" ]; then
- if [ -d "$mountpoint" ]; then
- mount -o remount,rw $mountpoint
- if (($?)); then
- error "Could not mount $mountpoint"
- exit 1
- fi
- fi
-fi
-
-# the backup procedure
-
-if [ ! -d "$backupdir/$folder/$folder.0" ]; then
- mkdir -p $backupdir/$folder/$folder.0
-fi
-
-info "Rotating $backupdir/$folder/$folder..."
-echo "Rotating $backupdir/$folder/$folder..." >> $log
-rotate $backupdir/$folder/$folder $keep
-info "Wget'ing $SECTION on $backupdir/$folder/$folder.0..."
-
-if [ ! -z "$badnwidth" ]; then
- limit_rate="--limit-rate=$badnwidth""k"
-fi
-
-cd $backupdir/$folder/$folder.0
-wget $wget_options $limit-rate -r -c -N -e robots=off $url
-cd -
-
-$touch $backupdir/$folder/$folder.0
-
-# remount backup destination as read-only
-
-if [ "$read_only" == "1" ] || [ "$read_only" == "yes" ]; then
- mount -o remount,ro $mountpoint
-fi
-
-# check partition for errors
-
-if [ "$fscheck" == "1" ] || [ "$fscheck" == "yes" ]; then
- umount $mountpoint
- if (($?)); then
- warning "Could not umount $mountpoint to run fsck"
- else
- $nice $fsck -v -y $partition >> $log
- mount $mountpoint
- fi
-fi
-
-# removes the lockfile
-
-if [ ! -z "$lockfile" ]; then
- $rm $lockfile || warning "Could not remove lockfile $lockfile"
-fi
-
-echo "Finnishing backup at `date`" >> $log
-