Skip to content
Browse files

2005-12-05 Alexis Sukrieh <sukria@backup-manager.org>

	* BackupManager/Config.pm:
	  + fixed some typos.
	* backup-manager:
	  + removed some comments, cleaning.
	* backup-manager-upload:
	  + deletes expired files on remote FTP hosts (closes: #1).
	  + error when the repository is not readable (closes: #2).
	  + using other ports than 22 is possible for SSH transfers, new
	  configuration key "BM_UPLOAD_SSH_PORT" (closes: #5).
	* backup-manager.conf.tpl:
	  + New confkeys for the upload methods, BM_UPLOAD_SSH_*, BM_UPLOAD_FTP_*
	* lib/actions.sh:
	  + Code cleaning, upload_files() now uses the new stuff in
	  lib/upload-methods.sh
	* lib/files.sh:
	  + unmount_tmp_dir() now unmount $mount_point only if it's already
	  mounted (closes: #6).
	* lib/sanitize.sh:
	  + New sanitizers for the new configuration keys.
	* lib/upload-methods.sh:
	  + New library for handling every upload methods, implemented here ssh
	  and ftp methods.




git-svn-id: svn://svn.backup-manager.org/backup-manager/trunk@258 2e458433-d701-0410-9826-f9b593394a3c
  • Loading branch information...
1 parent 0950922 commit 00dfa771f7a7db5fb448c979ddff86ed7c230deb sukria committed Dec 5, 2005
Showing with 338 additions and 246 deletions.
  1. +1 −1 BackupManager/Config.pm
  2. +25 −0 ChangeLog
  3. +1 −0 Makefile
  4. +1 −33 backup-manager
  5. +60 −31 backup-manager-upload
  6. +34 −55 backup-manager.conf.tpl
  7. +84 −91 lib/actions.sh
  8. +5 −0 lib/backup-methods.sh
  9. +3 −1 lib/files.sh
  10. +1 −14 lib/logger.sh
  11. +15 −19 lib/sanitize.sh
  12. +107 −0 lib/upload-methods.sh
  13. +1 −1 man/backup-manager-upload.8
View
2 BackupManager/Config.pm
@@ -18,7 +18,7 @@ use warnings;
=head2 getopt()
-Comes from debconf, thanks Joe ;)
+Comes from debconf, thanks joeyh ;)
first arg : $usage (text to be written on STDERR if help is needed).
View
25 ChangeLog
@@ -1,3 +1,28 @@
+2005-12-05 Alexis Sukrieh <sukria@backup-manager.org>
+
+ * BackupManager/Config.pm:
+ + fixed some typos.
+ * backup-manager:
+ + removed some comments, cleaning.
+ * backup-manager-upload:
+ + deletes expired files on remote FTP hosts (closes: #1).
+ + error when the repository is not readable (closes: #2).
+ + using other ports than 22 is possible for SSH transfers, new
+ configuration key "BM_UPLOAD_SSH_PORT" (closes: #5).
+ * backup-manager.conf.tpl:
+ + New confkeys for the upload methods, BM_UPLOAD_SSH_*, BM_UPLOAD_FTP_*
+ * lib/actions.sh:
+ + Code cleaning, upload_files() now uses the new stuff in
+ lib/upload-methods.sh
+ * lib/files.sh:
+ + unmount_tmp_dir() now unmount $mount_point only if it's already
+ mounted (closes: #6).
+ * lib/sanitize.sh:
+ + New sanitizers for the new configuration keys.
+ * lib/upload-methods.sh:
+ + New library for handling every upload methods, implemented here ssh
+ and ftp methods.
+
2005-11-23 Alexis Sukrieh <sukria@backup-manager.org>
* backup-manager:
View
1 Makefile
@@ -9,6 +9,7 @@ SHFILES=lib/dialog.sh \
lib/files.sh \
lib/actions.sh \
lib/backup-methods.sh\
+ lib/upload-methods.sh\
lib/logger.sh \
lib/gettext.sh \
lib/gettext-real.sh \
View
34 backup-manager
@@ -47,6 +47,7 @@ source $libdir/dialog.sh
source $libdir/files.sh
source $libdir/md5sum.sh
source $libdir/backup-methods.sh
+source $libdir/upload-methods.sh
source $libdir/actions.sh
# Initialize defautls values of arguments
@@ -129,90 +130,57 @@ while [ $# -ge 1 ]; do
shift
done
-# source the wanted conffile...
source $conffile
-
-# ...And check that every conf key is ok
source $libdir/sanitize.sh
-# check that no other backup-manager is running
get_lock
-
-# check dependencies on zip, bzip2
check_filetypes
-
-# check the directories list to backup is not empty
check_what_to_backup
-
-# set the default stuff
init_default_vars
-# This is the time for pre-command
exec_pre_command || error "Unable to exec the pre-command"
-# create $ARCHIVES_REPOSITORY if not exists
create_archive_root_if_not_exists
-##############################################################
-# Single actions handling
-#############################################################
-
-# only the uploading system
if [ "$upload" == "true" ]; then
upload_files
_exit 0
fi
-# only the burning system
if [ "$burn" == "true" ]; then
burn_files
_exit 0
fi
-# only the md5 checkup
if [ "$md5check" == "true" ]; then
check_cdrom_md5_sums
_exit 0
fi
-# only purge old archives
if [ "$purge" == "true" ]; then
clean_repositories
_exit 0
fi
-##############################################################
# Default process : doing everything unless --no-flags
# are given.
-#############################################################
-# first cleanning up the repository
if [ "$nopurge" != "true" ]; then
clean_repositories
fi
-# now generating new archives...
-# FIXME: here we will manage multiple archive method
-# like
-# make_tarballs
-# make_rsync
-# ....
make_archives
-# upload if needed
if [ "$noupload" != "true" ]; then
upload_files
fi
-# burn if wanted
if [ "$noburn" != "true" ]; then
burn_files
fi
-# this is time for post-command
exec_post_command || error "Unable to exec post-command"
-# release the lock concerned by this conffile
release_lock
exit 0
View
91 backup-manager-upload
@@ -79,16 +79,9 @@ use strict;
use warnings;
use BackupManager::Config;
use BackupManager::Logger;
-
use POSIX qw(strftime);
-
-
-#
# global vars
-#
-
-
my $scp = '/usr/bin/scp';
my $g_verbose = 0;
my $g_list = 0;
@@ -103,7 +96,7 @@ my $g_key_file = undef;
# first get the args
BackupManager::Config::getopt("$0 -m=mode -h=host -u=user [options] date\n
--v|--verbose : Print on STDOUT what happends.
+-v|--verbose : Print on STDOUT what happens.
-m|--mode : Transfer mode to use : ftp or scp.
-h|--host : Remote hosts to connect to (separated by commas).
-u|--user : User to use for connection.
@@ -168,29 +161,42 @@ sub send_file_with_scp($$$$)
defined $user and
defined $host and
defined $location;
-
+
+ # look for a port to use
+ my $port_switch="";
+ if ($ENV{BM_UPLOAD_SSH_PORT}) {
+ $port_switch = "-P ".$ENV{BM_UPLOAD_SSH_PORT};
+ }
+
+ my $log_file = `mktemp /tmp/bm-upload.XXXXXX`;
+ chomp $log_file;
+ unless (-f $log_file) {
+ error "cannot create log file: '$log_file'";
+ }
+
my $cmd;
if (defined $g_key_file and -f $g_key_file) {
- $cmd = "$scp -i $g_key_file -B $file $user".'@'.$host.':'.$location." >/dev/null 2>&1";
+ $cmd = "$scp -i $g_key_file $port_switch -B $file $user".'@'.$host.':'.$location." >$log_file 2>&1";
}
else {
- $cmd = "$scp -B $file $user".'@'.$host.':'.$location." >/dev/null 2>&1";
+ $cmd = "$scp $port_switch -B $file $user".'@'.$host.':'.$location." >$log_file 2>&1";
}
-
# we use eval here to avoid crash with bad keys
my $ret = eval "system('$cmd')";
if ($@ or $ret) {
- error "$scp failed for $file : $@ (command was : $cmd)" if $@;
- error "$scp failed for $file (command was : $cmd)" if $ret;
+ error "$scp failed for $file : $@ (command was : $cmd). " if $@;
+ error "$scp failed for $file (command was : $cmd). Check logs in $log_file" if $ret;
+ verbose_error "Unable to upload $file, check $log_file";
return 0;
}
+ unlink $log_file;
return 1;
}
-# How to uplaod files with scp.
+# How to upload files with scp.
# Note that Key Authentification is used, see man ssh-keygen.
sub send_files_with_scp($$$$)
{
@@ -206,7 +212,7 @@ sub send_files_with_scp($$$$)
# is scp here ?
unless (-x $scp) {
- verbose_error "$scp is not here, cannot use this mode for transfert";
+ verbose_error "$scp is not here, cannot use this mode for transfer.";
exit 1;
}
@@ -217,16 +223,37 @@ sub send_files_with_scp($$$$)
if (-f $file and send_file_with_scp($file, $user, $host, $repository)) {
verbose "File $file uploaded successfully.";
}
- elsif (-f $file) {
- verbose_error "File $file cannot be uploaded, check ${user}'s ssh keys on host $host";
- }
- else {
+ elsif (! -f $file) {
verbose_error "File $file cannot be uploaded, it does not exist locally.";
}
}
}
}
+# Function for purging a directory
+# over FTP, the same way as the repository is purged.
+# Every files with a date field too old according to BM_ARCHIVE_TTL
+# will be deleted.
+sub ftp_clean_directory($)
+{
+ my $ftp = shift;
+ my $BM_ARCHIVE_TTL = $ENV{BM_ARCHIVE_TTL};
+ return 0 unless defined $BM_ARCHIVE_TTL;
+ my $date_to_remove = `date +%Y%m%d --date "$BM_ARCHIVE_TTL days ago"`;
+
+ my $ra_files = $ftp->ls();
+ foreach my $file (@$ra_files) {
+ my $date = undef;
+ if ($file =~ /\.(\d{8})\./) {
+ $date = $1;
+ if ($date and ($date <= $date_to_remove)) {
+ verbose "$file has to be deleted, too old ($date <= $date_to_remove).";
+ $ftp->delete ($file) or error "Unable to delete $file.";
+ }
+ }
+ }
+ return 1;
+}
# How to upload files with ftp.
# We'll use the Net::FTP module here.
@@ -235,7 +262,7 @@ sub send_files_with_ftp($$$$$)
# trying to get Net::FTP.
eval "use Net::FTP";
if ($@) {
- error "Net::FTP is not available, cannot use ftp transfert mode";
+ error "Net::FTP is not available, cannot use ftp transfer mode";
return 0;
}
@@ -261,16 +288,7 @@ sub send_files_with_ftp($$$$$)
$ftp->cwd($repository)) {
verbose "Logged on $host, in $repository (binary mode)";
- # Purge the FTP repository if needed
- if ($g_ftpclean) {
- verbose "Cleaning FTP folder $repository";
- my $ra_files = $ftp->ls();
- foreach my $file (@$ra_files) {
- unless ($ftp->delete($file)) {
- verbose_error "Unable to delete $file";
- }
- }
- }
+ ftp_clean_directory($ftp) if ($g_ftpclean);
foreach my $file (@{$ra_files}) {
chomp $file;
@@ -333,6 +351,17 @@ sub get_files_list_from_date($)
exit 1;
}
+ # make sure we can read the root dir, when the secure mode is
+ # enabled, the repository might not be readable by us...
+ unless (-r $g_root_dir) {
+ verbose_error "The repository $g_root_dir is not readable by user \"$ENV{USER}\".";
+ if ($ENV{BM_REPOSITORY_SECURE} eq "yes") {
+ verbose_error "The secure mode is enabled (BM_REPOSITORY_SECURE),";
+ verbose_error "the upload user ($g_user) must be in the group \"BM_REPOSITORY_GROUP\".";
+ }
+ exit 1;
+ }
+
while (<$g_root_dir/*$date*>) {
push @{$ra_files}, $_;
}
View
89 backup-manager.conf.tpl
@@ -11,15 +11,12 @@
##############################################################
# Repository - everything about where archives are
#############################################################
-
# Where to store the archives
export BM_REPOSITORY_ROOT="/var/archives"
-
# For security reasons, the archive repository and the generated
# archives will be readable/writable by a given user/group.
# This is recommended to set this to yes.
export BM_REPOSITORY_SECURE="yes"
-
# The repository will be readable/writable only by a specific
# user:group pair if BM_REPOSITORY_SECURE is set to yes.
export BM_REPOSITORY_USER="root"
@@ -28,15 +25,12 @@ export BM_REPOSITORY_GROUP="root"
##############################################################
# Archives - let's focus on the precious tarballs...
##############################################################
-
# Number of days we have to keep an archive (Time To Live)
export BM_ARCHIVE_TTL="5"
-
# Do you want to replace duplicates by symlinks?
# (archive-DAY is a duplicate of archive-(DAY - 1) if they
# are both the same size).
export BM_ARCHIVE_PURGEDUPS="yes"
-
# Prefix of every archive on that box (default is HOSTNAME)
export BM_ARCHIVE_PREFIX="$HOSTNAME"
@@ -53,38 +47,30 @@ export BM_ARCHIVE_METHOD="tarball"
# Section "TARBALL"
# - Backup method: tarball
#############################################################
-
# Archive filename format
# long : host-full-path-to-folder.tar.gz
# short : parentfolder.tar.gz
export BM_TARBALL_NAMEFORMAT="long"
-
# Type of archives, available types are tar, tar.gz, tar.bz2, zip.
export BM_TARBALL_FILETYPE="tar.gz"
-
# Do you want to dereference the files pointed by symlinks ?
# enter yes or no (yes can lead to huge archives, be careful).
export BM_TARBALL_DUMPSYMLINKS="no"
-
# Directories you want to backup as tarballs (separated by spaces)
export BM_TARBALL_DIRECTORIES="/etc /home"
-
# Files to exclude when generating tarballs
export BM_TARBALL_BLACKLIST=""
##############################################################
# The tarball-incremental method uses the same keys as the
# tarball method, plus two others.
#############################################################
-
# Which frequency to use for the master tarball?
# possible values: weekly, monthly
export BM_TARBALLINC_MASTERDATETYPE="weekly"
-
# Number of the day, in the BM_TARBALLINC_MASTERDATETYPE frequency
# when master tarballs should be made
export BM_TARBALLINC_MASTERDATEVALUE="1"
-
# Examples: you want to make maser tarballs every friday:
# BM_TARBALLINC_MASTERDATETYPE="weekly"
# BM_TARBALLINC_MASTERDATEVALUE="5"
@@ -99,32 +85,24 @@ export BM_TARBALLINC_MASTERDATEVALUE="1"
# This method is dedicated to MySQL databases.
# You should not use the tarball method for backing up database
# directories or you may have corrupted archives.
-
# Enter here the list of databases
export BM_MYSQL_DATABASES="mysql"
-
# The user who is allowed to read every databases filled in BM_MYSQL_DATABASES
export BM_MYSQL_ADMINLOGIN="root"
-
# its password
export BM_MYSQL_ADMINPASS=""
-
# the host where the database is
export BM_MYSQL_HOST="localhost"
-
# the port where MySQL listen to on the host
export BM_MYSQL_PORT="3306"
-
# which compression format to use? (gzip or bzip2)
export BM_MYSQL_FILETYPE="bzip2"
##############################################################
# Backup method: svn
#############################################################
-
# Absolute paths to the svn repositories to archive
export BM_SVN_REPOSITORIES=""
-
# You can compress the resulting XML files
# Supported compressor are: bzip2 and gzip
export BM_SVN_COMPRESSWITH="bzip2"
@@ -174,34 +152,47 @@ export BM_PIPE_COMPRESS
##############################################################
# Section "UPLOAD"
-# - The upload system allow you to send the archives to
-# to remote hosts, either with FTP or SSH.
+# You can upload archives to remote hosts with different
+# methods.
#############################################################
-
-# The list of remote hosts, if you want to enable the upload
-# system, just put some remote hosts here (fqdn or IPs)
+# Which method to use for uploading archives
+# For only the SSH method: BM_UPLOAD_METHOD="ssh"
+# For both SSH and FTP methods: BM_UPLOAD_METHOD="ssh ftp"
+export BM_UPLOAD_METHOD=""
+# where to upload (global to all methods)
export BM_UPLOAD_HOSTS=""
+# Where to put archives on the remote hosts (global)
+export BM_UPLOAD_DESTINATION=""
-# which protocol to use for tranfers? (scp or ftp)
-export BM_UPLOAD_MODE=""
-
-# User for opening the remote connection
-export BM_UPLOAD_USER=""
-
-# Password, only needed for ftp transfer, scp is based on key authentication
-export BM_UPLOAD_PASSWD=""
-
-# cleans specified ftp folder before uploading (yes or no)
-export BM_UPLOAD_FTPPURGE=""
+##############################################################
+# The SSH method
+#############################################################
+# the user to use for the SSH connections/transfers
+export BM_UPLOAD_SSH_USER=""
+# The private key to use for opening the connection
+export BM_UPLOAD_SSH_KEY=""
+# specific ssh hosts
+export BM_UPLOAD_SSH_HOSTS=""
+# destination for ssh uploads (overrides BM_UPLOAD_DESTINATION)
+export BM_UPLOAD_SSH_DESTINATION=""
-# if scp mode is used, an identity file is needed
-export BM_UPLOAD_KEY=""
+##############################################################
+# The FTP method
+#############################################################
+# the user to use for the FTP connections/transfers
+export BM_UPLOAD_FTP_USER=""
+# the FTP user's password
+export BM_UPLOAD_FTP_PASSWORD=""
+# FTP specific rmeote hosts
+export BM_UPLOAD_FTP_HOSTS=""
+# purge archives on remote hosts before uploading?
+export BM_UPLOAD_FTP_PURGE="no"
+# destination for FTP uploads (overrides BM_UPLOAD_DESTINATION)
+export BM_UPLOAD_FTP_DESTINATION=""
-#"/backup/upload/"
-export BM_UPLOAD_DIR=""
##############################################################
-# Upload method: RSYNC
+# The RSYNC method
#############################################################
# Which directories should be backuped with rsync
@@ -211,18 +202,6 @@ BM_RSYNC_DIRECTORIES=""
# system, just put some remote hosts here (fqdn or IPs)
export BM_RSYNC_HOSTS=""
-# User for opening the remote connection
-export BM_UPLOAD_SSH_USER=""
-
-# Rsync needs an identity file
-export BM_UPLOAD_SSH_KEY=""
-
-# Do you want to dereference the files pointed by symlinks?
-# enter yes or no (yes can lead to huge archives, be careful).
-export BM_TARBALL_DUMPSYMLINKS="no"
-
-
-
##############################################################
# Section "BURNING"
# - Automatic CDR/CDRW burning
View
175 lib/actions.sh
@@ -1,8 +1,72 @@
+# Copyright (C) 2005 The Backup Manager Authors
#
-# The backup-manager's actions.sh library.
+# See the AUTHORS file for details.
#
-# Every major feature of backup-manager is here.
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# Major features of backup manager are here.
+
+# Loop on the backup methods
+make_archives()
+{
+ for method in $BM_ARCHIVE_METHOD
+ do
+ case $method in
+ mysql)
+ backup_method_mysql
+ ;;
+ rsync)
+ backup_method_rsync
+ ;;
+ tarball|tarball-incremental)
+ backup_method_tarball
+ ;;
+ pipe)
+ backup_method_pipe
+ ;;
+ svn)
+ backup_method_svn
+ ;;
+ *)
+ error "No such backup method: \$BM_ARCHIVE_METHOD"
+ ;;
+ esac
+done
+}
+
+# Loop on the upload methods
+upload_files ()
+{
+ for method in $BM_UPLOAD_METHOD
+ do
+ case $method in
+ ftp|FTP)
+ bm_upload_ftp
+ ;;
+ ssh|SSH|scp|SCP)
+ bm_upload_ssh
+ ;;
+ rsync|RSYNC)
+ bm_upload_rsync
+ ;;
+ *)
+ warning "The upload method \"\$method\" is not supported; skipping."
+ ;;
+ esac
+ done
+}
# This will get all the md5 sums of the day,
# mount the BM_BURNING_DEVICE on /tmp/device and check
@@ -119,8 +183,11 @@ burn_files()
title="Backups of ${TODAY}"
- # Let's un mount the device first
- umount $BM_BURNING_DEVICE || warning "Unable to unmount the device \$BM_BURNING_DEVICE"
+ # Let's unmount the device first
+ if grep $BM_BURNING_DEVICE /etc/mtab >/dev/null 2>&1; then
+ info "\$BM_BURNING_DEVICE is mounted, unmounting before the burning session."
+ umount $BM_BURNING_DEVICE || warning "Unable to unmount the device \$BM_BURNING_DEVICE"
+ fi
# get a log file in a secure path
logfile="$(mktemp /tmp/bm-cdrecord.log.XXXXXX)"
@@ -136,19 +203,19 @@ burn_files()
# burning the iso with the user choosen method
case "$BM_BURNING_METHOD" in
"DVD")
- if [ ! -x $growisofs ]; then
- error "DVD burning requires $growisofs, aborting."
- fi
+ if [ ! -x $growisofs ]; then
+ error "DVD burning requires $growisofs, aborting."
+ fi
info -n "Exporting archives to the DVD media in \$BM_BURNING_DEVICE: "
$growisofs -Z ${BM_BURNING_DEVICE} -R -J -V "${title}" ${what_to_burn} > ${logfile} 2>&1 ||
error "failed, check \$logfile"
info "ok"
;;
"CDRW")
- if [ ! -x $cdrecord ]; then
- error "CDROM burning requires $cdrecord, aborting."
- fi
+ if [ ! -x $cdrecord ]; then
+ error "CDROM burning requires $cdrecord, aborting."
+ fi
info -n "Blanking the CDRW in \$BM_BURNING_DEVICE: "
${cdrecord} -tao $devforced blank=fast > ${logfile} 2>&1 ||
@@ -162,19 +229,20 @@ burn_files()
info "ok"
;;
"CDR")
- if [ ! -x $cdrecord ]; then
- error "CDROM burning requires $cdrecord, aborting."
- fi
+
+ if [ ! -x $cdrecord ]; then
+ error "CDROM burning requires $cdrecord, aborting."
+ fi
info -n "Burning data to \$BM_BURNING_DEVICE: "
${mkisofs} -V "${title}" -q -R -J ${what_to_burn} | \
${cdrecord} -tao $devforced - > ${logfile} 2>&1 ||
error "failed, check \$logfile"
info "ok"
;;
- *)
- error "The requested burning method is not supported, check BM_BURNING_METHOD in \$conffile"
- ;;
+ *)
+ error "The requested burning method is not supported, check BM_BURNING_METHOD in \$conffile"
+ ;;
esac
# Cleaning the logile, everything was fine at this point.
@@ -187,36 +255,6 @@ burn_files()
fi
}
-
-make_archives()
-{
- info "Using the \"\$BM_ARCHIVE_METHOD\" backup method..."
- case $BM_ARCHIVE_METHOD in
-
- mysql)
- backup_method_mysql
- ;;
- rsync)
- backup_method_rsync
- ;;
- rsync-snapshots)
- backup_method_rsync-snapshots
- ;;
- tarball|tarball-incremental)
- backup_method_tarball
- ;;
- pipe)
- backup_method_pipe
- ;;
- svn)
- backup_method_svn
- ;;
- *)
- error "No such backup method: \$BM_ARCHIVE_METHOD"
- ;;
- esac
-}
-
# This will parse all the files contained in BM_REPOSITORY_ROOT
# and will clean them up. Using clean_directory() and clean_file().
clean_repositories()
@@ -226,51 +264,6 @@ clean_repositories()
}
-# This is the call to backup-manager-upload
-# with the appropriate options.
-# This will upload the files with scp or ftp.
-upload_files ()
-{
- if [ -n "$BM_UPLOAD_HOSTS" ]
- then
- if [ "$verbose" == "true" ]; then
- v="-v"
- else
- v=""
- fi
-
- if [ -z "$BM_UPLOAD_FTPPURGE" ] ||
- [ "$BM_UPLOAD_FTPPURGE" = "no" ]; then
- ftp_purge=""
- else
- ftp_purge="--ftp-purge"
- fi
-
- servers=`echo $BM_UPLOAD_HOSTS| sed 's/ /,/g'`
- if [ "$BM_UPLOAD_MODE" == "ftp" ]; then
- $bmu $v $ftp_purge \
- -m="$BM_UPLOAD_MODE" \
- -h="$servers" \
- -u="$BM_UPLOAD_USER" \
- -p="$BM_UPLOAD_PASSWD" \
- -d="$BM_UPLOAD_DIR" \
- -r="$BM_REPOSITORY_ROOT" today || error "unable to call backup-manager-upload"
- else
- if [ ! -z "$BM_UPLOAD_KEY" ]; then
- key_opt="-k=\"$BM_UPLOAD_KEY\""
- else
- key_opt=""
- fi
- su $BM_UPLOAD_USER -s /bin/sh -c \
- "$bmu $v -m="$BM_UPLOAD_MODE" \
- -h="$servers" \
- -u="$BM_UPLOAD_USER" $key_opt \
- -d="$BM_UPLOAD_DIR" \
- -r="$BM_REPOSITORY_ROOT" today" || error "unable to call backup-manager-upload"
- fi
- fi
-}
-
# This will run the pre-command given.
# If this command prints on STDOUT "false",
# backup-manager will stop here.
View
5 lib/backup-methods.sh
@@ -142,6 +142,8 @@ __exec_meta_command()
# configuration keys: BM_TARBALL_* and BM_TARBALLINC_*
backup_method_tarball()
{
+ info "Using method \"\$BM_ARCHIVE_METHOD\""
+
# Create the directories blacklist
blacklist=""
for pattern in $BM_TARBALL_BLACKLIST
@@ -266,6 +268,7 @@ backup_method_tarball()
backup_method_mysql()
{
+ info "Using method \"\$BM_ARCHIVE_METHOD\""
if [ ! -x $mysqldump ]; then
error "The \"mysql\" method is choosen, but \$mysqldump is not found."
fi
@@ -285,6 +288,7 @@ backup_method_mysql()
backup_method_svn()
{
+ info "Using method \"\$BM_ARCHIVE_METHOD\""
if [ ! -x $svnadmin ]; then
error "The \"svn\" method is choosen, but \$svnadmin is not found."
fi
@@ -305,6 +309,7 @@ backup_method_svn()
backup_method_pipe()
{
+ info "Using method \"\$BM_ARCHIVE_METHOD\""
index=0
# parse each BM_PIPE_NAME's
View
4 lib/files.sh
@@ -6,7 +6,9 @@
unmount_tmp_dir()
{
- if [ -n "$mount_point" ] && [ -d $mount_point ]; then
+ if [ -n "$mount_point" ] &&
+ [ -d $mount_point ] &&
+ [ grep $mount_point /etc/mtab >/dev/null 2>&1 ]; then
umount "$mount_point" > /dev/null 2>&1 || error "unable to unmount \$mount_point"
sleep 1
rmdir "$mount_point" > /dev/null 2>&1 || error "unable to remove \$mount_point"
View
15 lib/logger.sh
@@ -127,20 +127,7 @@ _exit()
release_lock
info "ok"
- if [ -n "$mount_point" ]; then
- if [ -d $mount_point ] && [ "$HAS_MOUNTED" = "1" ]; then
- info -n "Unmounting \$BM_BURNING_DEVICE: "
- umount $mount_point || true
- sleep 2
- info "ok"
- fi
-
- if [ -d $mount_point ]; then
- info -n "Removing \$mount_point: "
- rmdir $mount_point || true
- info "ok"
- fi
- fi
+ unmount_tmp_dir
exit $@
}
View
34 lib/sanitize.sh
@@ -137,27 +137,23 @@ if [ "$BM_BURNING" = "yes" ]; then
confkey_require "BM_BURNING_CHKMD5" "yes"
fi
-# the upload system
-if [ -n "$BM_UPLOAD_HOSTS" ]; then
- confkey_hanlde_deprecated "BM_FTP_PURGE" "BM_UPLOAD_FTPPURGE"
-
- if [ -z "$BM_UPLOAD_USER" ]; then
- confkey_error "BM_UPLOAD_USER" "BM_UPLOAD_HOSTS"
- fi
+# The SSH stuff
- if [ "$BM_UPLOAD_MODE" = "ftp" ] && [ -z "$BM_UPLOAD_PASSWD" ]; then
- # This one is not globalizable, the message is a real specific one.
- error "The configuration key BM_UPLOAD_PASSWD is not set but BM_UPLOAD_MODE is set to \"ftp\"."
- fi
+# The FTP stuff
- if [ -z "$BM_UPLOAD_MODE" ]; then
- confkey_error "BM_UPLOAD_MODE" "BM_UPLOAD_HOSTS"
- fi
-
- if [ -z "$BM_UPLOAD_DIR" ]; then
- confkey_error "BM_UPLOAD_DIR" "BM_UPLOAD_HOSTS"
- fi
-fi
+if [ -n "$BM_UPLOAD_MODE" ]; then
+ confkey_hanlde_deprecated "BM_UPLOAD_MODE" "BM_UPLOAD_METHOD"
+
+ confkey_hanlde_deprecated "BM_UPLOAD_USER" "BM_UPLOAD_SSH_USER"
+ confkey_hanlde_deprecated "BM_UPLOAD_KEY" "BM_UPLOAD_SSH_KEY"
+
+ confkey_hanlde_deprecated "BM_UPLOAD_USER" "BM_UPLOAD_FTP_USER"
+ confkey_hanlde_deprecated "BM_UPLOAD_PASSWD" "BM_UPLOAD_FTP_PASSWORD"
+ confkey_hanlde_deprecated "BM_FTP_PURGE" "BM_UPLOAD_FTP_PURGE"
+ confkey_hanlde_deprecated "BM_UPLOAD_FTPPURGE" "BM_UPLOAD_FTP_PURGE"
+
+ confkey_hanlde_deprecated "BM_UPLOAD_DIR" "BM_UPLOAD_DESTINATION"
+fi
if [ -z "$BM_LOGGER" ]; then
confkey_warning "BM_LOGGER" "yes"
View
107 lib/upload-methods.sh
@@ -0,0 +1,107 @@
+# Copyright (C) 2005 The Backup Manager Authors
+#
+# See the AUTHORS file for details.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# This is upload methods library.
+
+# Reads the configuration keys in order to set the
+# environement (hosts, sources, ...)
+bm_upload_init()
+{
+ hosts="$1"
+ bm_upload_hosts=$(echo $hosts| sed -e 's/ /,/g')
+
+ v_switch=""
+ if [ "$verbose" == "true" ]; then
+ v_switch="-v"
+ fi
+
+}
+
+# Manages SSH uploads
+bm_upload_ssh()
+{
+ info "Using the upload method \"ssh\"."
+
+ bm_upload_hosts="$BM_UPLOAD_HOSTS $BM_UPLOAD_SSH_HOSTS"
+ bm_upload_init "$bm_upload_hosts"
+
+ if [ -z "$BM_UPLOAD_SSH_DESTINATION" ]; then
+ BM_UPLOAD_SSH_DESTINATION="$BM_UPLOAD_DESTINATION"
+ fi
+ if [ -z "$BM_UPLOAD_SSH_DESTINATION" ]; then
+ error "No valid destination found, SSH upload not possible."
+ fi
+
+ # the flags for the SSH method
+ k_switch=""
+ if [ ! -z "$BM_UPLOAD_SSH_KEY" ]; then
+ k_switch="-k=\"$BM_UPLOAD_SSH_KEY\""
+ fi
+
+ # Call to backup-manager-upload
+ su $BM_UPLOAD_SSH_USER -s /bin/sh -c \
+ "$bmu $v_switch \
+ $k_switch \
+ -m=\"scp\" \
+ -h=\"$bm_upload_hosts\" \
+ -u=\"$BM_UPLOAD_SSH_USER\" \
+ -d=\"$BM_UPLOAD_SSH_DESTINATION\" \
+ -r=\"$BM_REPOSITORY_ROOT\" today" ||
+ error "Unable to call backup-manager-upload."
+}
+
+# Manages FTP uploads
+bm_upload_ftp()
+{
+ info "Using the upload method \"ftp\"."
+
+ bm_upload_hosts="$BM_UPLOAD_HOSTS $BM_UPLOAD_FTP_HOSTS"
+ bm_upload_init "$bm_upload_hosts"
+
+ if [ -z "$BM_UPLOAD_FTP_DESTINATION" ]; then
+ BM_UPLOAD_FTP_DESTINATION="$BM_UPLOAD_DESTINATION"
+ fi
+
+ if [ -z "$BM_UPLOAD_FTP_DESTINATION" ]; then
+ error "No valid destination found, FTP upload not possible."
+ fi
+
+ # flags for the FTP method
+ ftp_purge_switch=""
+ if [ "$BM_UPLOAD_FTPPURGE" == "yes" ] ||
+ [ "$BM_UPLOAD_FTPPURGE" = "true" ]; then
+ ftp_purge_switch="--ftp-purge"
+ fi
+
+ $bmu $v_switch $ftp_purge_switch \
+ -m="ftp" \
+ -h="$bm_upload_hosts" \
+ -u="$BM_UPLOAD_FTP_USER" \
+ -p="$BM_UPLOAD_FTP_PASSWORD" \
+ -d="$BM_UPLOAD_FTP_DESTINATION" \
+ -r="$BM_REPOSITORY_ROOT" today ||
+ error "unable to call backup-manager-upload"
+
+}
+
+# Manages RSYNC uploads
+bm_upload_rsync()
+{
+ error "The upload method \"rsync\" is not supported."
+}
+
View
2 man/backup-manager-upload.8
@@ -129,7 +129,7 @@
.\" ========================================================================
.\"
.IX Title "BACKUP-MANAGER-UPLOAD 1"
-.TH BACKUP-MANAGER-UPLOAD 1 "2005-09-29" "perl v5.8.7" "backup-manager-upload"
+.TH BACKUP-MANAGER-UPLOAD 1 "2005-12-04" "perl v5.8.7" "backup-manager-upload"
.SH "NAME"
backup\-manager\-upload \- Multiprotocol uploader for backup\-manager.
.SH "SYNOPSIS"

0 comments on commit 00dfa77

Please sign in to comment.
Something went wrong with that request. Please try again.