From eabda5615cccbb9031ba989e1eb9729215eae95a Mon Sep 17 00:00:00 2001 From: Jerome Charaoui Date: Fri, 29 Jun 2018 16:50:41 -0400 Subject: [PATCH] Remove vserver support (fixes #11289) This is probably completely unused by now, as vservers have been superseeded by alternative technology for many years already. --- .gitignore | 1 - README.md | 23 +--- etc/backupninja.conf.in | 6 - examples/example.dup | 15 --- examples/example.mysql | 8 -- examples/example.pgsql | 5 - examples/example.rdiff | 17 +-- examples/example.rsync | 7 -- examples/example.svn | 3 - examples/example.sys | 4 - handlers/dup.helper.in | 102 +--------------- handlers/dup.in | 37 +----- handlers/mysql.helper.in | 36 +----- handlers/mysql.in | 141 +++++----------------- handlers/pgsql.helper.in | 26 +--- handlers/pgsql.in | 122 +++++-------------- handlers/rdiff.helper.in | 97 ++------------- handlers/rdiff.in | 36 ------ handlers/rsync.in | 34 ------ handlers/svn.in | 46 ++----- handlers/sys.helper.in | 4 - handlers/sys.in | 61 ---------- handlers/tar.in | 6 - lib/Makefile.am | 8 +- lib/vserver.in | 251 --------------------------------------- man/backupninja.conf.5 | 8 -- man/ninjahelper.1 | 3 +- src/backupninja.in | 5 - src/ninjahelper.in | 3 - 29 files changed, 89 insertions(+), 1026 deletions(-) delete mode 100644 lib/vserver.in diff --git a/.gitignore b/.gitignore index c8d4bc9..8ba50e3 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 61a255e..23a7845 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 7e3d347..7625a27 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 b7221a0..7b869d5 100644 --- a/examples/example.dup +++ b/examples/example.dup @@ -137,21 +137,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 | ... (default = all) -## vsinclude = -## vsinclude = -## ... -## 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 de9651f..a0e386b 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 = (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 5a4e02f..d36ec38 100644 --- a/examples/example.pgsql +++ b/examples/example.pgsql @@ -1,10 +1,5 @@ ### backupninja PostgreSQL config file ### -# vsname = (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 = (default: /var/backups/postgres) # where to dump the backups diff --git a/examples/example.rdiff b/examples/example.rdiff index 226c21e..18940e6 100644 --- a/examples/example.rdiff +++ b/examples/example.rdiff @@ -103,7 +103,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 @@ -129,21 +129,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 | ... (default = all) -## vsinclude = -## vsinclude = -## ... -## 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 dcf0ad0..ca995ee 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] @@ -121,11 +119,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 ea43601..0a64f09 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 f1b5973..85bc650 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 | ... (default = all) diff --git a/handlers/dup.helper.in b/handlers/dup.helper.in index 4a15269..2048479 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 @@ -366,7 +308,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 @@ -384,45 +326,14 @@ 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 + set -o noglob + for i in $dup_includes; do + echo "include = $i" >> $next_filename + done + set +o noglob cat >> $next_filename < ... (default = all) -# vsinclude = -# vsinclude = -# ... -# 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 <> $next_filename < (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 e793151..f57b315 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 82e6b48..89a8c77 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 < (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 < (default: /var/backups/postgres) # where to dump the backups $pgsql_backupdir diff --git a/handlers/pgsql.in b/handlers/pgsql.in index 31a2168..7669a3c 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 e2ddc46..324915b 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 < ... (default = all) -# vsinclude = -# vsinclude = -# ... -# 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 4e2b31b..fdc5114 100644 --- a/handlers/rdiff.in +++ b/handlers/rdiff.in @@ -116,24 +116,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 that the ionicelevel is valid if [ -n "$ionicelevel" ] && echo "$ionicelevel" | grep -vq "^[0-7]$"; then fatal "The value of ionicelevel is expected to be either empty or an integer from 0 to 7. Got: $ionicelevel" @@ -255,24 +237,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 9257eed..8b0c0ad 100644 --- a/handlers/rsync.in +++ b/handlers/rsync.in @@ -57,7 +57,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) @@ -98,9 +97,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 @@ -175,7 +171,6 @@ function eval_config { getconf filelistbase getconf include getconf exclude - getconf exclude_vserver getconf numericids 0 getconf compress 0 @@ -981,8 +976,6 @@ function set_rsync_options { rsync_options=($rsync_options --rsync-path="$remote_rsync") fi - include_vservers - } function stop_services { @@ -1056,33 +1049,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 bb70eee..94afe5c 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 c584dfb..3390792 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 | ... (default = all) EOF chmod 600 $next_filename } diff --git a/handlers/sys.in b/handlers/sys.in index 78436f3..8ae2eef 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 afe3e8b..991d665 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 9a54736..2180adc 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 b356b2b..0000000 --- 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 a87bab7..35ae584 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 0135f69..a6e319f 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 6da7237..8f614ec 100755 --- a/src/backupninja.in +++ b/src/backupninja.in @@ -507,7 +507,6 @@ fi # include shared functions . $libdirectory/tools -. $libdirectory/vserver setfile $conffile @@ -546,10 +545,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 4b4dceb..1ab727a 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