diff --git a/.gitignore b/.gitignore index c8d4bc9defa5844ca5955f6b622c2ee80c384fb3..8ba50e30e7a88427d10a27e48a413e4b59102cc4 100644 --- a/.gitignore +++ b/.gitignore @@ -47,7 +47,6 @@ lib/Makefile lib/easydialog lib/parseini lib/tools -lib/vserver man/Makefile src/Makefile src/backupninja diff --git a/README.md b/README.md index 61a255edd1b90b6d09c95f3392b0155ae705f15a..23a7845914e21378c497a9465160b78d18c1b512 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,6 @@ The key features of backupninja are: - console-based wizard (ninjahelper) makes it easy to create backup action configuration files - passwords are never sent via the command line to helper programs - - works with [Linux-Vservers](http://linux-vserver.org/) The following backup types are supported: @@ -82,8 +81,7 @@ To add an additional 'wizard' to ninjahelper, follow these steps: } 3. Look at the existing helpers to see how they are written. Try to re-use - functions, such as the dialog functions that are defined in `easydialog.sh`, - or the vserver functions defined in `lib/vserver`. + functions, such as the dialog functions that are defined in `easydialog.sh`. 4. Test, re-test, and test again. Try to break the helper by going backwards, try to think like someone who has no idea how to configure your handler @@ -215,25 +213,6 @@ Since it performs incremental backups it minimizes the number of request per operation therefore reducing the costs. The boto Python interface to Amazon Web Services is needed to use duplicity with S3 (Debian package: `python-boto`). - -Vservers --------- - -If you are using [Linux-Vservers](http://linux-vserver.org/) there are some -special capabilities that different handlers have to make vserver -backups easier. - -Set the variable `vservers` to be `yes` in `/etc/backupninja.conf` and see the -example configuration files for each handler to configure the vserver specific -variables. - -Additional vserver variables that can be configured in `/etc/backupninja.conf`, -but they probably don't need to be changed: - - - `VSERVERINFO` (default: `/usr/sbin/vserver-info`) - - `VSERVER` (default: `/usr/sbin/vserver`) - - `VROOTDIR` (default: `$VSERVERINFO info SYSINFO |grep vserver-Rootdir | awk '{print $2}'`) - .sh configuration files ----------------------- diff --git a/etc/backupninja.conf.in b/etc/backupninja.conf.in index 7e3d347d0c1f9b53dfc00fb7f3cfd5576dd82d68..7625a27510f552889f8ba8bf818189388a696606 100644 --- a/etc/backupninja.conf.in +++ b/etc/backupninja.conf.in @@ -72,9 +72,6 @@ usecolors = yes # default value for 'when' when = everyday at 01:00 -# if running vservers, set to yes -vservers = no - # programs paths # SLAPCAT=/usr/sbin/slapcat # LDAPSEARCH=/usr/bin/ldapsearch @@ -89,6 +86,3 @@ vservers = no # GZIP=/bin/gzip # GZIP_OPTS='--rsyncable' # RSYNC=/usr/bin/rsync -# VSERVERINFO=/usr/sbin/vserver-info -# VSERVER=/usr/sbin/vserver -# VROOTDIR=/var/lib/vservers diff --git a/examples/example.dup b/examples/example.dup index bfeccc6e243f8e402452b45bf081a1162978b56e..1497d7da82d71f1dd87db88c59a05e9effe8b907 100644 --- a/examples/example.dup +++ b/examples/example.dup @@ -127,21 +127,6 @@ include = /usr/local/sbin include = /var/lib/dpkg/status include = /var/lib/dpkg/status-old -## 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. - # files to exclude from the backup exclude = /home/*/.gnupg exclude = /var/cache/backupninja/duplicity diff --git a/examples/example.mysql b/examples/example.mysql index de9651fb5e1b6e6cda11855e98bbbbe214ce296a..a0e386b10d55074e5386cf4496e8b2da1504ce0c 100644 --- a/examples/example.mysql +++ b/examples/example.mysql @@ -79,11 +79,3 @@ compress = yes # # compress = < yes | no > (default = yes) # if yes, compress the sqldump output. -# -# 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 -# -# NB: databases = all doesn't seem to work with hotcopy = yes -# when vsname is specified, I would like to know how to fix this. diff --git a/examples/example.pgsql b/examples/example.pgsql index 5a4e02f05f657a4e41ee7ff0fadf65d777b3d15d..d36ec3807893f5ddb5b189303cffabf74a05d9f9 100644 --- a/examples/example.pgsql +++ b/examples/example.pgsql @@ -1,10 +1,5 @@ ### 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. - # backupdir = <dir> (default: /var/backups/postgres) # where to dump the backups diff --git a/examples/example.rdiff b/examples/example.rdiff index 323b3ebec99e4a0c7c00b0bdf504670785ba0113..d21845ceacd4abfca1232938f3a0c4e86d4e2226 100644 --- a/examples/example.rdiff +++ b/examples/example.rdiff @@ -93,7 +93,7 @@ type = local # keep = 60 ## A few notes about includes and excludes: -## 1. include, exclude and vsinclude statements support globbing with '*' +## 1. include and exclude 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 @@ -119,21 +119,6 @@ include = /usr/local/sbin include = /var/lib/dpkg/status include = /var/lib/dpkg/status-old -## 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. - ## files to exclude from the backup exclude = /home/*/.gnupg exclude = /var/cache/backupninja/duplicity diff --git a/examples/example.rsync b/examples/example.rsync index e4cea15172fc33f0ebcf5e831df8c1501b8a80c0..acdf860d21cd28f1651f49323597ab17fce73e3c 100644 --- a/examples/example.rsync +++ b/examples/example.rsync @@ -4,8 +4,6 @@ # Mandatory options are uncommented with sugested values # Other options are commented out with their default values # -# Note: You dont need to manually specify vservers using "include = /vservers". -# They're automatically backuped if vserver is set to "yes" on you backupninja.conf. [general] @@ -111,11 +109,6 @@ include = /var exclude = exclude_folder1 exclude = exclude_folder2 -# exlude some vserver from backup -# this is used only if vservers = yes on backupninja.conf -exclude_vserver = excluded_vserver1 -exclude_vserver = excluded_vserver2 - # ssh command line (remote only) #ssh = ssh diff --git a/examples/example.svn b/examples/example.svn index ea4360130e2687554ed9eef30a81c8035c6ff448..0a64f0908b1aa74978525de817c3e3568da5572f 100644 --- a/examples/example.svn +++ b/examples/example.svn @@ -21,6 +21,3 @@ ## in /usr/share/doc/subversion/examples now if you wish to use ## it instead # HOTBACKUP = /usr/lib/subversion/hot-backup.py - -## the name of the vserver containing svn, if using vservers -# vsname = diff --git a/examples/example.sys b/examples/example.sys index f1b59735ec68d4baa6de957d658f8039f350e9e9..85bc650e282b29403a5917f144481d39b0574f1f 100644 --- a/examples/example.sys +++ b/examples/example.sys @@ -79,7 +79,3 @@ # note: to backup your BIOS, you need the program 'flashrom' installed, and your # mainboard needs to be supported, see http://flashrom.org/Supported_hardware#Supported_mainboards # bios = no - -# If vservers = yes in /etc/backupninja.conf then the following variables can -# be used: -# vsnames = all | <vserver1> <vserver2> ... (default = all) diff --git a/handlers/dup.helper.in b/handlers/dup.helper.in index 7515623972edc24ef5e2b1df5479a2626da26070..45d25dae3978ba958afeaa87b22c0fb4e58fe1c6 100644 --- a/handlers/dup.helper.in +++ b/handlers/dup.helper.in @@ -30,35 +30,6 @@ do_dup_host_includes() { 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 "" - formItem include "" - formItem include "" - 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" @@ -80,35 +51,6 @@ do_dup_excludes() { 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 @@ -362,7 +304,7 @@ signpassword = $dup_gpg_signpassword [source] # A few notes about includes and excludes: -# 1. include, exclude and vsinclude statements support globbing with '*' +# 1. include and exclude 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 @@ -380,43 +322,12 @@ signpassword = $dup_gpg_signpassword # 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 + set -o noglob + for i in $dup_includes; do + echo "include = $i" >> $next_filename + done + set +o noglob - # excludes cat >> $next_filename <<EOF # files to exclude from the backup @@ -601,7 +512,6 @@ dup_wizard() { _adv_done= dup_includes= dup_excludes= - dup_vsincludes= dup_incremental=yes dup_increments=30 dup_keep=60 diff --git a/handlers/dup.in b/handlers/dup.in index d304ed16580c52a4df6cd0700280cb1507b6f245..e3eec11d4dd4601e0ac5e611e6cdadfc311a7c00 100644 --- a/handlers/dup.in +++ b/handlers/dup.in @@ -19,8 +19,6 @@ getconf signkey setsection source getconf include -getconf vsnames all -getconf vsinclude getconf exclude setsection dest @@ -48,7 +46,7 @@ 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 "$include" ] || fatal "No source includes specified" [ -n "$password" ] || fatal "The password option must be set." if [ -n "$signkey" -a -n "$encryptkey" -a "$signkey" != "$encryptkey" ]; then [ -n "$signpassword" ] || fatal "The signpassword option must be set because signkey is different from encryptkey." @@ -80,25 +78,6 @@ if [ "`echo $desturl | @AWK@ -F ':' '{print $1}'`" == "file" ]; then fi fi -### VServers -# If vservers are configured, check that the ones listed in $vsnames do exist. -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 @@ -259,20 +238,6 @@ for i in $include; do done IFS=$SAVEIFS -# vsincludes -if [ $usevserver = yes ]; then - for vserver in $vsnames; do - SAVEIFS=$IFS - IFS=$(echo -en "\n\b") - for vi in $vsinclude; do - str="${vi//__star__/*}" - str="$VROOTDIR/$vserver$str" - execstr_source="${execstr_source} --include '$str'" - done - IFS=$SAVEIFS - done -fi - set +o noglob ### EXECUTE #################################################################### diff --git a/handlers/mysql.helper.in b/handlers/mysql.helper.in index 997f73c0a8ebe4bf40c0e02f5de6e6859a818901..543435011b67734fd498e7b389f898df5bef16c7 100644 --- a/handlers/mysql.helper.in +++ b/handlers/mysql.helper.in @@ -3,12 +3,6 @@ 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 @@ -121,20 +115,6 @@ $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 @@ -145,22 +125,8 @@ 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 + inputBox "$mysql_title" "Directory where to store the backups" "/var/backups/mysql" [ $? = 1 ] && return mysql_backupdir="backupdir = $REPLY" diff --git a/handlers/mysql.in b/handlers/mysql.in index e7931518e79c936ad3081ade414410fb361ee547..f57b315f377690e34ef65d1295fed8928863bb78 100644 --- a/handlers/mysql.in +++ b/handlers/mysql.in @@ -13,7 +13,6 @@ 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 @@ -22,27 +21,6 @@ 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. -usevserver=no -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 @@ -51,21 +29,15 @@ for i in $ignores $nodata; do ignore="$ignore --ignore-table=$i" done -# create backup dirs, $vroot will be empty if no vsname was specified +# create backup dirs # 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'" +[ -d $backupdir ] || mkdir -p $backupdir +[ -d $backupdir ] || fatal "Backup directory '$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 +[ "$sqldump" == "no" -o -d $dumpdir ] || mkdir -p $dumpdir +[ "$hotcopy" == "no" -o -d $hotdir ] || mkdir -p $hotdir ####################################################################### ## AUTHENTICATION @@ -88,23 +60,13 @@ defaultsfile="" if [ -n "$dbusername" -a -n "$dbpassword" ] then - if [ $usevserver = yes ] - then - home=`$VSERVER $vsname exec getent passwd "root" | @AWK@ -F: '{print $6}'` - else - home=`getent passwd "root" | @AWK@ -F: '{print $6}'` - fi + home=`getent passwd "root" | @AWK@ -F: '{print $6}'` [ -d $home ] || fatal "Can't find root's home directory ($home)." mycnf="$home/.my.cnf" - if [ $usevserver = yes ] - then - workcnf="$vroot$mycnf" - else - workcnf="$mycnf" - fi + workcnf="$mycnf" if [ -f $workcnf ] then @@ -145,28 +107,18 @@ EOF elif [ -n "$user" ] then userset=true; - if [ $usevserver = yes ] + + userhome=`getent passwd "$user" | @AWK@ -F: '{print $6}'` + if [ $? -eq 2 ] then - userhome=`$VSERVER $vsname exec getent passwd "$user" | @AWK@ -F: '{print $6}'` - if [ $? -eq 2 ] - then - fatal "User $user not found in /etc/passwd" - fi - debug "User home set to: $vroot$userhome" - [ -f $vroot$userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf" - else - userhome=`getent passwd "$user" | @AWK@ -F: '{print $6}'` - if [ $? -eq 2 ] - then - fatal "User $user not found in /etc/passwd" - fi - debug "User home set to: $userhome" - [ -f $userhome/.my.cnf ] || fatal "Can't find config file in $userhome/.my.cnf" + fatal "User $user not found in /etc/passwd" 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" -# otherwise use $configfile + # otherwise use $configfile else user=root defaultsfile="--defaults-extra-file=$configfile" @@ -180,13 +132,7 @@ 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 + execstr="$MYSQLHOTCOPY --quiet --allowold --regexp /.\*/./.\*/ $hotdir" debug "su $user -c \"$execstr\"" if [ ! $test ] then @@ -204,12 +150,7 @@ then 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 + execstr="$MYSQLHOTCOPY --allowold $db $hotdir" debug 'su $user -c \"$execstr\"' if [ ! $test ] then @@ -236,20 +177,10 @@ then info "Initializing SQL dump method" if [ "$databases" == "all" ] then - if [ $usevserver = yes ] + databases=$(set -o pipefail ; su $user -c "$MYSQL $defaultsfile -N -B -e 'show databases'" | sed 's/|//g;/\+----/d;/^\(information\|performance\)_schema$/d') + if [ $? -ne 0 ] then - debug 'set -o pipefail ; echo show databases | $VSERVER $vsname exec su $user -c \"$MYSQL $defaultsfile\" | grep -v Database | grep -v '"'"'^\(information\|performance\)_schema$'"'" - databases=`set -o pipefail ; echo 'show databases' | $VSERVER $vsname exec su $user -c "$MYSQL $defaultsfile" | grep -v Database | grep -v '^\(information\|performance\)_schema$'` - if [ $? -ne 0 ] - then - fatal "Authentication problem, maybe user/password is wrong or mysqld is not running?" - fi - else - databases=$(set -o pipefail ; su $user -c "$MYSQL $defaultsfile -N -B -e 'show databases'" | sed 's/|//g;/\+----/d;/^\(information\|performance\)_schema$/d') - if [ $? -ne 0 ] - then - fatal "Authentication problem, maybe user/password is wrong or mysqld is not running?" - fi + fatal "Authentication problem, maybe user/password is wrong or mysqld is not running?" fi fi @@ -275,31 +206,19 @@ then 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 $GZIP_OPTS > '$vroot$dumpdir/${db}.sql.gz'" - else - execstr="$VSERVER $vsname exec $DUMP -r '$vroot$dumpdir/${db}.sql'" - fi + + # 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 $GZIP_OPTS > '$dumpdir/${db}.sql.gz'" 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 $GZIP_OPTS > '$dumpdir/${db}.sql.gz'" - else - execstr="$DUMP > '$dumpdir/${db}.sql'" - fi + execstr="$DUMP > '$dumpdir/${db}.sql'" fi debug "su $user -c \"$execstr\"" + if [ ! $test ] then output=`su $user -s /bin/bash -c "set -o pipefail ; $execstr" 2>&1` diff --git a/handlers/pgsql.helper.in b/handlers/pgsql.helper.in index 82e6b485d660b5fe2fa800aa67624b5d79a90961..89a8c77a0ae7e81e3e0b68d24254a879765881b5 100644 --- a/handlers/pgsql.helper.in +++ b/handlers/pgsql.helper.in @@ -3,12 +3,6 @@ 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 @@ -37,16 +31,8 @@ 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" + inputBox "$pgsql_title" "Directory where to store the backups:" "/var/backups/postgres" [ $? = 1 ] && return pgsql_backupdir="backupdir = $REPLY" @@ -87,16 +73,6 @@ pgsql_wizard() { 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 diff --git a/handlers/pgsql.in b/handlers/pgsql.in index 31a2168b66011ff9150c598859079c9aea2f196a..7669a3c4e9a248b5116d801fd1662117dacca184 100644 --- a/handlers/pgsql.in +++ b/handlers/pgsql.in @@ -7,85 +7,39 @@ getconf backupdir /var/backups/postgres getconf databases all getconf compress yes -getconf vsname # format maps to pg_dump --format= option, old/default was plain getconf format plain 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. -usevserver=no -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" ] && [ "$format" = "plain" ]; then - [ -x "$vroot`$VSERVER $vsname exec which $PGSQLDUMPALL`" ] || \ - fatal "Can't find $PGSQLDUMPALL in vserver $vsname." - elif [ "$format" != "plain" ]; then - [ -x "$vroot`$VSERVER $vsname exec which $PGSQLDUMPALL`" ] || \ - fatal "Can't find $PGSQLDUMPALL in vserver $vsname." - [ -x "$vroot`$VSERVER $vsname exec which $PGSQLDUMP`" ] || \ - fatal "Can't find $PGSQLDUMP in vserver $vsname." - [ -x "$vroot`$VSERVER $vsname exec which $PSQL`" ] || \ - fatal "Can't find $PSQL in vserver $vsname." - else - [ -x "$vroot`$VSERVER $vsname exec which $PGSQLDUMP`" ] || \ - fatal "Can't find $PGSQLDUMP in vserver $vsname." - fi +if [ "$databases" == "all" ] && [ "$format" = "plain" ]; then + [ -x "`which $PGSQLDUMPALL`" ] || \ + fatal "Can't find $PGSQLDUMPALL." +elif [ "$format" != "plain" ]; then + [ -x "`which $PGSQLDUMPALL`" ] || \ + fatal "Can't find $PGSQLDUMPALL." + [ -x "`which $PGSQLDUMP`" ] || \ + fatal "Can't find $PGSQLDUMP." + [ -x "`which $PSQL`" ] || \ + fatal "Can't find $PSQL." else - if [ "$databases" == "all" ] && [ "$format" = "plain" ]; then - [ -x "`which $PGSQLDUMPALL`" ] || \ - fatal "Can't find $PGSQLDUMPALL." - elif [ "$format" != "plain" ]; then - [ -x "`which $PGSQLDUMPALL`" ] || \ - fatal "Can't find $PGSQLDUMPALL." - [ -x "`which $PGSQLDUMP`" ] || \ - fatal "Can't find $PGSQLDUMP." - [ -x "`which $PSQL`" ] || \ - fatal "Can't find $PSQL." - else - [ -x "`which $PGSQLDUMP`" ] || \ - fatal "Can't find $PGSQLDUMP." - fi + [ -x "`which $PGSQLDUMP`" ] || \ + fatal "Can't find $PGSQLDUMP." 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." +# create backup dir +[ -d $backupdir ] || (debug "mkdir -p $backupdir"; mkdir -p $backupdir) +[ -d $backupdir ] || fatal "Backup directory '$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 +pguid=`getent passwd $PGSQLUSER | @AWK@ -F: '{print $3}'` +[ -n "$pguid" ] || fatal "No user called $PGSQLUSER." + +debug "chown $pguid $backupdir" +chown $pguid $backupdir +debug "chmod 700 $backupdir" +chmod 700 $backupdir # If we are using the custom (best) or tar pg_dump format, and @@ -93,11 +47,7 @@ chmod 700 $vroot$backupdir # of all non-template databases to avoid the use of pg_dumpall. dumpglobals="no" if [ "$databases" = "all" ] && [ "$format" != "plain" ]; then - cmdprefix="" - if [ "$usevserver" = "yes" ]; then - cmdprefix="$VSERVER $vsname exec " - fi - execstr="${cmdprefix} su - $PGSQLUSER -c 'psql -AtU $PGSQLUSER -c \"SELECT datname FROM pg_database WHERE NOT datistemplate\"'" + execstr="su - $PGSQLUSER -c 'psql -AtU $PGSQLUSER -c \"SELECT datname FROM pg_database WHERE NOT datistemplate\"'" debug execstr dblist="" for db in $(eval $execstr 2>&1); do @@ -113,18 +63,10 @@ fi # if $databases = all, use pg_dumpall if [ "$databases" == "all" ]; then - if [ $usevserver = yes ]; then - if [ "$compress" == "yes" ]; then - execstr="$VSERVER $vsname exec su - $PGSQLUSER -s /bin/bash -c \"set -o pipefail ; $PGSQLDUMPALL | $GZIP $GZIP_OPTS > '$backupdir/${vsname}.sql.gz'\"" - else - execstr="$VSERVER $vsname exec su - $PGSQLUSER -c \"$PGSQLDUMPALL > '$backupdir/${vsname}.sql'\"" - fi + if [ "$compress" == "yes" ]; then + execstr="su - $PGSQLUSER -s /bin/bash -c \"set -o pipefail ; $PGSQLDUMPALL | $GZIP $GZIP_OPTS > '$backupdir/${localhost}-all.sql.gz'\"" else - if [ "$compress" == "yes" ]; then - execstr="su - $PGSQLUSER -s /bin/bash -c \"set -o pipefail ; $PGSQLDUMPALL | $GZIP $GZIP_OPTS > '$backupdir/${localhost}-all.sql.gz'\"" - else - execstr="su - $PGSQLUSER -c \"$PGSQLDUMPALL > '$backupdir/${localhost}-all.sql'\"" - fi + execstr="su - $PGSQLUSER -c \"$PGSQLDUMPALL > '$backupdir/${localhost}-all.sql'\"" fi debug "$execstr" if [ ! $test ]; then @@ -151,11 +93,7 @@ else else globalscmd="$PGSQLDUMPALL -g > '$backupdir/globals.sql'" fi - if [ $usevserver = yes ]; then - execstr="$VSERVER $vsname exec su - $PGSQLUSER -s /bin/bash -c \"$globalscmd\"" - else - execstr="su - $PGSQLUSER -s /bin/bash -c \"$globalscmd\"" - fi + execstr="su - $PGSQLUSER -s /bin/bash -c \"$globalscmd\"" debug "$execstr" if [ ! $test ]; then output=`eval $execstr 2>&1` @@ -188,11 +126,7 @@ else else dumpcmd="$PGSQLDUMP --format=$format ${disablecustomcompress} $db > '$backupdir/${db}.${dumpext}'" fi - if [ $usevserver = yes ]; then - execstr="$VSERVER $vsname exec su - $PGSQLUSER -s /bin/bash -c \"$dumpcmd\"" - else - execstr="su - $PGSQLUSER -s /bin/bash -c \"$dumpcmd\"" - fi + execstr="su - $PGSQLUSER -s /bin/bash -c \"$dumpcmd\"" debug "$execstr" if [ ! $test ]; then output=`eval $execstr 2>&1` diff --git a/handlers/rdiff.helper.in b/handlers/rdiff.helper.in index e2ddc46a0545a416a61e904026a5452790b6c6f8..324915b6eb2f672b6898050ba74b0cb278f4face 100644 --- a/handlers/rdiff.helper.in +++ b/handlers/rdiff.helper.in @@ -5,8 +5,6 @@ HELPERS="$HELPERS rdiff:incremental_remote_filesystem_backup" declare -a rdiff_includes declare -a rdiff_excludes -declare -a rdiff_vsincludes -declare -a rdiff_vsexcludes # FUNCTIONS @@ -35,38 +33,6 @@ do_rdiff_host_includes() { 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 "" - formItem include "" - formItem include "" - 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" @@ -90,27 +56,8 @@ do_rdiff_excludes() { } do_rdiff_src() { - choose_host_or_vservers_or_both "$rdiff_title" + do_rdiff_host_includes [ $? = 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)" @@ -314,7 +261,7 @@ type = local keep = $rdiff_keep # A few notes about includes and excludes: -# 1. include, exclude and vsinclude statements support globbing with '*' +# 1. include and exclude 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 @@ -332,40 +279,11 @@ keep = $rdiff_keep # 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 + set -o noglob + for ((i=0; i < ${#rdiff_includes[@]} ; i++)); do + echo "include = ${rdiff_includes[$i]}" >> $next_filename + done + set +o noglob ## excludes ## set -o noglob @@ -439,7 +357,6 @@ rdiff_wizard() { 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 /var/cache/backupninja/duplicity) - rdiff_vsincludes= set +o noglob rdiff_main_menu diff --git a/handlers/rdiff.in b/handlers/rdiff.in index 2a06d2ec8cecd0dd13aa8fd32d83f8c41ae6e847..3f6bdb974b738a4a8e093c27b94f842f5f1f43f4 100644 --- a/handlers/rdiff.in +++ b/handlers/rdiff.in @@ -115,24 +115,6 @@ fi ### CHECK CONFIG ### -# If vservers are configured, check that the ones listed in $vsnames do exist. -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 @@ -243,24 +225,6 @@ for i in $include; do done IFS=$SAVEIFS -# vsinclude -if [ $usevserver = yes ]; then - for vserver in $vsnames; do - SAVEIFS=$IFS - IFS=$(echo -en "\n\b") - 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 - IFS=$SAVEIFS - done -fi - set +o noglob # exclude everything else diff --git a/handlers/rsync.in b/handlers/rsync.in index 8cad073b50fcf9d1c44fb69776da041fd2ac3c23..d35ca6aea931faa41f7ec10e573d1a942528872e 100644 --- a/handlers/rsync.in +++ b/handlers/rsync.in @@ -56,7 +56,6 @@ # protocol = ssh or rsync (remote source 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 bandwidth limit in KB/s (remote source only) @@ -97,9 +96,6 @@ # 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. -# # function definitions @@ -173,7 +169,6 @@ function eval_config { getconf filelistbase getconf include getconf exclude - getconf exclude_vserver getconf numericids 0 getconf compress 0 @@ -975,8 +970,6 @@ function set_rsync_options { rsync_options=($rsync_options --rsync-path="$remote_rsync") fi - include_vservers - } function stop_services { @@ -1050,33 +1043,6 @@ function run_fsck { } -function include_vservers { - - # 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 - -} - function start_mux { if [ "$multiconnection" == "yes" ]; then diff --git a/handlers/svn.in b/handlers/svn.in index bb70eee14fd1b608300659173631ab59f696bfa2..94afe5ce8daf1293a4053806ccf6855033160dc5 100644 --- a/handlers/svn.in +++ b/handlers/svn.in @@ -12,66 +12,40 @@ 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. -usevserver=no -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 +cd $src for repo in `find . -name svnserve.conf` do repo=`dirname $repo` repo=`dirname $repo` - ret=`mkdir -p $vroot$tmp/$repo 2>&1` + ret=`mkdir -p $tmp/$repo 2>&1` code=$? if [ "$ret" ]; then debug "$ret" fi if [ $code != 0 ]; then - error "command failed mkdir -p $vroot$tmp/$repo" + error "command failed mkdir -p $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 + ret=`$HOTBACKUP $src/$repo $tmp/$repo 2>&1` code=$? if [ "$ret" ]; then debug "$ret" fi if [ $code != 0 ]; then - error "command failed -- $HOTBACKUP $vroot$src/$repo $vroot$tmp/$repo" + error "command failed -- $HOTBACKUP $src/$repo $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" + echo "Error: because of earlier errors, we are leaving svn backups in $tmp instead of $dest" else - if [ -d $vroot$dest -a -d $vroot$tmp ]; then - rm -rf $vroot$dest + if [ -d $dest -a -d $tmp ]; then + rm -rf $dest fi - if [ -d $vroot$tmp ]; then - mv $vroot$tmp $vroot$dest + if [ -d $tmp ]; then + mv $tmp $dest fi fi diff --git a/handlers/sys.helper.in b/handlers/sys.helper.in index c584dfb51d698d6b10b58b39d04bfc47418901c3..339079282447151e1af1a4f70894caa58f9d3978 100644 --- a/handlers/sys.helper.in +++ b/handlers/sys.helper.in @@ -50,10 +50,6 @@ $bios # 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 index e037b2fafd4cadbebdc60466a02a145c5893cf65..6539f415715f228225c0f4a2163f1b7192a8e613 100644 --- a/handlers/sys.in +++ b/handlers/sys.in @@ -126,21 +126,6 @@ getconf mbrfile $parentdir/mbr.__star__.bin getconf FLASHROM `which flashrom` getconf bios no -getconf vsnames all - -# If vservers are configured, check that the ones listed in $vsnames are running. -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 @@ -186,47 +171,6 @@ fi # 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 @@ -551,11 +495,6 @@ if [ $os = "redhat" ]; then 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 diff --git a/handlers/tar.in b/handlers/tar.in index 7497306c8bb88d19e4e999f611320bd2db757a1c..473aa1de226e9d51b216411f590189dc8ab41423 100644 --- a/handlers/tar.in +++ b/handlers/tar.in @@ -14,12 +14,6 @@ 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" diff --git a/lib/Makefile.am b/lib/Makefile.am index 9a54736a2353906a139c38141a8c59fad313e42e..2180adc6e43e0fc8a5bbe08dfff1c1b9bffcc226 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -1,9 +1,9 @@ my_execbindir = $(pkglibdir) -my_execbin_SCRIPTS = easydialog parseini tools vserver +my_execbin_SCRIPTS = easydialog parseini tools CLEANFILES = $(my_execbin_SCRIPTS) -EXTRA_DIST = easydialog.in parseini.in tools.in vserver.in +EXTRA_DIST = easydialog.in parseini.in tools.in edit = sed \ -e "s,@CFGDIR\@,$(CFGDIR),g" \ @@ -24,7 +24,3 @@ parseini: $(srcdir)/parseini.in tools: $(srcdir)/tools.in rm -f tools $(edit) tools.in > tools - -vserver: $(srcdir)/vserver.in - rm -f vserver - $(edit) vserver.in > vserver diff --git a/lib/vserver.in b/lib/vserver.in deleted file mode 100644 index b356b2b42697449a739e3e0f654c9d7d46f2f391..0000000000000000000000000000000000000000 --- a/lib/vserver.in +++ /dev/null @@ -1,251 +0,0 @@ -# -*- mode: sh; sh-basic-offset: 3; indent-tabs-mode: nil; -*- -# vim: set filetype=sh sw=3 sts=3 expandtab autoindent: - -##################################################### -## VSERVERS RELATED FUNCTIONS FOR NINJAHELPER -## -## Depends on: -## - easydialog library -## - $conffile -## -## Global variables used and modified here: -## - $vservers_are_available (yes/no) -## - $found_vservers (list) -## - $selected_vservers (list) -## - $host_or_vservers (host/vservers/both) -## - -## -## Get vservers-related variables. -## Then, if Vservers are enabled, check that: -## - VROOTDIR is valid; -## - at least one vserver can be found. -## If, and only if, the above conditions are all true: -## - set $vservers_are_available to 'yes'; -## - set $found_vservers to the list of all vservers found on the system. -## This function has to be run once before a new helper is run. -## If the argument is "nodialog", use the backupninja's message functions -## instead of easydialog. -## -init_vservers() { - local arg=$1 - # get global variables from the conffile - setfile $conffile - getconf vservers no - getconf VSERVERINFO /usr/sbin/vserver-info - getconf VSERVER /usr/sbin/vserver - getconf VROOTDIR `if [ -x "$VSERVERINFO" ]; then $VSERVERINFO info SYSINFO | grep '^ *vserver-Rootdir' | @AWK@ '{print $2}'; fi` - # canonicalize VROOTDIR - [ -z "$VROOTDIR" ] || VROOTDIR=`readlink --canonicalize $VROOTDIR` - # init this library's global variables - vservers_are_available=no - found_vservers= - selected_vservers= - host_or_vservers=host - # check vservers real availability - if [ $vservers = yes ]; then - if [ ! -x "$VSERVERINFO" ]; then - `if [ "$arg" = nodialog ]; then echo fatal; else echo "msgBox warning"; fi` \ - "vservers enabled in $conffile, but vserver-info command was not found. Please set the VSERVERINFO configuration variable to its full path." - return - fi - if [ ! -x "$VSERVER" ]; then - `if [ "$arg" = nodialog ]; then echo fatal; else echo "msgBox warning"; fi` \ - "vservers enabled in $conffile, but vserver command was not found. Please set the VSERVER configuration variable to its full path." - return - fi - if [ -z "$VROOTDIR" ]; then - `if [ "$arg" = nodialog ]; then echo fatal; else echo "msgBox warning"; fi` \ - "vservers enabled in $conffile, but VROOTDIR is not set and could not be guessed." - return - fi - if [ ! -d "$VROOTDIR" ]; then - `if [ "$arg" = nodialog ]; then echo fatal; else echo "msgBox warning"; fi` \ - "vservers enabled in $conffile, but VROOTDIR ($VROOTDIR) does not exist."; - return - fi - found_vservers=`ls $VROOTDIR | grep -E -v "lost\+found|ARCHIVES" | tr "\n" " "` - if [ -z "$found_vservers" ]; then - `if [ "$arg" = nodialog ]; then echo warning; else echo "msgBox warning"; fi` \ - "vservers enabled in $conffile, but no vserver was found in $VROOTDIR."; - return - fi - vservers_are_available=yes - fi -} - -## -## If all the arguments are existing vservers names, returns 0. -## Else, returns 1. Also returns 1 if no argument is given. -## -vservers_exist() { - [ $# -ge 1 ] || return 1 - local args="$1" - local vserver i found - for vserver in $args ; do - found=no - for i in $found_vservers ; do - if [ $vserver = $i ]; then - found=yes - break - fi - done - [ $found = yes ] || return 1 - done - return 0 -} - -## -## If all the arguments are running vservers names, returns 0. -## Else, returns 1. Also returns 1 if no argument is given. -## -vservers_running() { - [ $# -ge 1 ] || return 1 - local args="$1" - local vserver - for vserver in $args ; do - $VSERVERINFO -q $vserver RUNNING || return 1 - done - return 0 -} - -## -## If the argument is the name of a vserver selected by the current helper, -## echoes 'on' and returns 0. -## Else, echoes 'off' and returns 1. -## -vserver_is_selected() { - local vserver=$1 - local vserver_is_selected=1 - local i - for i in $selected_vservers ; do - [ "$vserver" == "$i" ] && vserver_is_selected=0 - done - if [ $vserver_is_selected = 0 ]; then - echo on - else - echo off - fi - return $vserver_is_selected -} - -## -## Have the user choose one Vserver among the existing ones. -## Set $selected_vservers to the chosen one's name. -## Returns 1 if cancelled or if Vservers are not available. -## -choose_one_vserver() { - [ "$vservers_are_available" == "yes" ] || return 1 - local title=$1 - local i= - local vserver= - REPLY= - while [ -z "$REPLY" ]; do - [ -n "$selected_vservers" ] && setDefault $selected_vservers - listBegin "$title" "Choose at least one Linux-Vserver to backup:" - for vserver in $found_vservers; do - listItem "$vserver" "Backup $vserver vserver" - done - listDisplay menu - [ $? = 0 ] || return 1 - done - selected_vservers=$REPLY -} - -## -## If Vservers are not enabled, set host_or_vservers='host' and then return -## Else, have the user choose if he/she wants to perform the backup on the host -## system or on one Vserver. -## Set, respectively, $host_or_vservers to 'host' or 'vservers'. -## Returns 1 if cancelled. -## -choose_host_or_one_vserver() { - if [ "$vservers_are_available" != "yes" ] - then - host_or_vservers='host' - return - fi - local title=$1 - # if there is one, set the previously chosen item as the default - [ -n "$host_or_vservers" ] && setDefault $host_or_vservers - menuBox "$title - src" "Do you want to operate on the host system and/or on vservers?" \ - "host" "Host system" \ - "vserver" "One Vserver" - [ $? = 0 ] || return 1 - case $REPLY in - "host") - host_or_vservers='host' - ;; - "vserver") - host_or_vservers='vservers' - ;; - esac -} - -## -## If Vservers are not enabled, set host_or_vservers='host' and then return -## Else, have the user choose the target he/she wants to perform the backup on: -## - host system only; -## - some vservers only; -## - both the host system and some vservers. -## Set, respectively, $host_or_vservers to 'host', 'vservers', or 'both' -## Returns 1 if cancelled. -## -choose_host_or_vservers_or_both() { - if [ "$vservers_are_available" != "yes" ] - then - host_or_vservers='host' - return - fi - local title=$1 - # if there is one, set the previously chosen item as the default - [ -n "$host_or_vservers" ] && setDefault $host_or_vservers - menuBox "$title - src" "Do you want to operate on the host system and/or on vservers?" \ - "host" "Host system only" \ - "vservers" "Vservers only" \ - "both" "Host system and Vservers" - [ $? = 0 ] || return 1 - case $REPLY in - "host") - host_or_vservers='host' - ;; - "vservers") - host_or_vservers='vservers' - ;; - "both") - host_or_vservers='both' - ;; - esac -} - -## -## Have the user choose among "all vservers" and a not-empty subset of these. -## Set $selected_vservers to 'all' or to a space-separated name list. -## Returns 1 if cancelled or if Vservers are not available. -## -choose_one_or_more_vservers() { - [ "$vservers_are_available" == "yes" ] || return 1 - local title=$1 - local i= - # UI - booleanBox "$title" "Do you want to backup all vservers?" ` [ -z "$selected_vservers" -o "$selected_vservers" == "all" ] || echo no` - if [ $? = 0 ]; then - selected_vservers="all" - else - # choose among the existing vservers - local vserver= - local vserver_was_selected= - REPLY= - while [ -z "$REPLY" ]; do - listBegin "$title" "Choose at least one Linux-Vserver to backup:" - # list existing vservers, preselecting the previously selected ones - for vserver in $found_vservers; do - listItem "$vserver" "Backup $vserver vserver" `vserver_is_selected $vserver` - done - listDisplay checklist - [ $? = 0 ] || return 1 - done - # remove quotes around each vserver name - selected_vservers=`echo $REPLY | tr -d '"'` - fi -} diff --git a/man/backupninja.conf.5 b/man/backupninja.conf.5 index a87bab7aeb8b353e0ad5818aa9f26040db6df453..35ae584aaf0ec35cce5ea76b2217c4f82b08a49d 100644 --- a/man/backupninja.conf.5 +++ b/man/backupninja.conf.5 @@ -97,12 +97,6 @@ These values for 'when' are invalid: when = tues at 02 .TP -.B vservers -If you are using Linux-Vservers (http://linux-vserver.org), there are some -special capabilities that different handlers have to make vserver backups easier. -See the example configuration files for each handler to configure the vserver specific -variables. - .SH DEFAULTS loglevel = 4 @@ -122,8 +116,6 @@ scriptdirectory = /usr/share/backupninja usecolors = yes .br when = everyday at 01:00 -.br -vservers = no .SH SEE ALSO .BR backupninja (1), diff --git a/man/ninjahelper.1 b/man/ninjahelper.1 index 0135f693fa73145d3125d7cbfb7a5fc14306d588..a6e319f3df9a5e952ca72184b983c29df474cc23 100644 --- a/man/ninjahelper.1 +++ b/man/ninjahelper.1 @@ -45,8 +45,7 @@ HELPERS="$HELPERS blue:description_of_this_helper" } .IP (3) look at the existing helpers to see how they are written. Try to re-use -functions, such as the dialog functions that are defined in easydialog.sh, -or the vserver functions defined in lib/vserver. +functions, such as the dialog functions that are defined in easydialog.sh. .IP (4) test, re-test, and test again. Try to break the helper by going backwards, try to think like someone who has no idea how to configure your handler diff --git a/src/backupninja.in b/src/backupninja.in index 756c67816c7d8df45414105ff761a1ca87275e58..c5af4f9d8da5f8aff238ccd178df2c9030d3f0df 100755 --- a/src/backupninja.in +++ b/src/backupninja.in @@ -504,7 +504,6 @@ fi # include shared functions . $libdirectory/tools -. $libdirectory/vserver setfile $conffile @@ -543,10 +542,6 @@ getconf DSYNC /usr/bin/dsync getconf DOVEADM /usr/bin/doveadm getconf admingroup root -# initialize vservers support -# (get config variables and check real vservers availability) -init_vservers nodialog - if [ ! -d "$configdirectory" ]; then echo "Configuration directory '$configdirectory' not found." fatal "Configuration directory '$configdirectory' not found." diff --git a/src/ninjahelper.in b/src/ninjahelper.in index 4b4dceb555659b26d3b693f3116c2db4f2699607..1ab727a1726de3c00c88713e3bc741cea04755cf 100755 --- a/src/ninjahelper.in +++ b/src/ninjahelper.in @@ -43,8 +43,6 @@ require_packages() { ## menu for the wizards ## donew() { - # (re-)initialize vservers support - init_vservers # menu listBegin "new action menu" "select an action to create" listItem return "return to main menu" @@ -202,7 +200,6 @@ fi # include shared functions . $libdirectory/easydialog . $libdirectory/tools -. $libdirectory/vserver # am I running as root? if [ "$UID" != "0" ]; then