aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@gnu.org.ua>2012-10-30 11:37:46 +0200
committerSergey Poznyakoff <gray@gnu.org.ua>2012-10-30 11:39:59 +0200
commit70f09e06f7f400fa4fbabf0c4fff09cd2208a932 (patch)
tree69d6128e2a09da648d7a81f90d25cd8a1918bfc0
parentdbd71155f0bb40e435163ddd2c73c991a4f8e787 (diff)
downloadbeam-70f09e06f7f400fa4fbabf0c4fff09cd2208a932.tar.gz
beam-70f09e06f7f400fa4fbabf0c4fff09cd2208a932.tar.bz2
Create database dumps in temporary directory.
* backup.in: Set safe umask. * lib/beam/common.in (backup_tmp_dir): New global variable. * beam.conf: Add backup_tmp_dir variable. * doc/beam.conf.5in: Document new variables. * lib/beam/mysql.sh: Create temporary files in backup_tmp_dir * lib/beam/postgres.sh: Likewise.
-rw-r--r--backup.in5
-rw-r--r--beam.conf3
-rw-r--r--doc/beam.conf.5in13
-rw-r--r--lib/beam/common.in1
-rwxr-xr-xlib/beam/mysql.sh8
-rwxr-xr-xlib/beam/postgres.sh8
6 files changed, 26 insertions, 12 deletions
diff --git a/backup.in b/backup.in
index 046953d..615fa12 100644
--- a/backup.in
+++ b/backup.in
@@ -121,6 +121,8 @@ backup() {
logit "finished"
}
+umask ${backup_umask:-077}
+
if [ -n "$backup_logfile" ]; then
runhook openlog_hook
exec >>$backup_logfile
@@ -129,11 +131,8 @@ fi
if [ -z "$backup_notify_email" ]; then
backup
else
- u=$(umask)
- umask 077
report=$backup_snapshot_dir/report.$$
touch $report
- umask $u
backup 2>&1 | tee $report
mail_report $report
rm $report
diff --git a/beam.conf b/beam.conf
index cc8be64..ce09da7 100644
--- a/beam.conf
+++ b/beam.conf
@@ -49,6 +49,9 @@ epilogue_hook=
# If zero or empty, backups are retained forever.
backup_retain_interval=
+# Directory for temporary files
+backup_tmp_dir=/tmp
+
##########################################################################
# S3 configuration.
##########################################################################
diff --git a/doc/beam.conf.5in b/doc/beam.conf.5in
index c519fef..69277a7 100644
--- a/doc/beam.conf.5in
+++ b/doc/beam.conf.5in
@@ -14,7 +14,7 @@
.\" You should have received a copy of the GNU General Public License
.\" along with BEAM. If not, see <http://www.gnu.org/licenses/>.
.\"
-.TH BEAM.CONF 5 "October 24, 2012" "BEAM" "BEAM User Reference"
+.TH BEAM.CONF 5 "October 30, 2012" "BEAM" "BEAM User Reference"
.SH NAME
beam.conf \- configuration file for
.B BEAM
@@ -35,6 +35,17 @@ used by the backup scripts begin with
.BR backup_ .
.SH GENERAL SETUP
.TP
+.BR backup_umask = \fIMASK\fR
+Sets file mode creation mask. This mask will apply to all files
+created during the backup: archives, snapshots and temporary files.
+The default mask is
+.BR 077 .
+.TP
+.BR backup_tmp_dir = \fIDIR\fR
+Sets the directory where temporary files will be stored. The default
+is
+.BR /tmp .
+.TP
.BR backup_logfile = \fIFILE\fR
If set, redirect standard error and standard output to that file. The
file will be created if it does not exist. Otherwise, the output will be
diff --git a/lib/beam/common.in b/lib/beam/common.in
index 4c6cd21..1be075e 100644
--- a/lib/beam/common.in
+++ b/lib/beam/common.in
@@ -30,6 +30,7 @@ backup_archive_dir=
backup_snapshot_dir=
backup_verbose=
backup_logfile="/var/log/backup"
+backup_tmp_dir=/tmp
error() {
echo >&2 $0: $*
diff --git a/lib/beam/mysql.sh b/lib/beam/mysql.sh
index 4ce3a88..185fa48 100755
--- a/lib/beam/mysql.sh
+++ b/lib/beam/mysql.sh
@@ -61,9 +61,9 @@ mysql_backup() {
cmd="$cmd --databases"
fi
if [ -z "$dry_run" ]; then
- $cmd $database > $backup_snapshot_dir/$1-$week-$round-$level
+ $cmd $database > $backup_tmp_dir/$1-$week-$round-$level
else
- echo "$cmd $database > $backup_snapshot_dir/$1-$week-$round-$level"
+ echo "$cmd $database > $backup_tmp_dir/$1-$week-$round-$level"
fi
if [ $? -ne 0 ]; then
@@ -73,9 +73,9 @@ mysql_backup() {
logit "creating $1-$week-$round-$level.$tar_suffix"
$dry_run tar $verbose $taroptions \
-f $backup_archive_dir/$1-$week-$round-$level.$tar_suffix \
- -C $backup_snapshot_dir $1-$week-$round-$level
+ -C $backup_tmp_dir $1-$week-$round-$level
tarcode $?
- $dry_run rm $backup_snapshot_dir/$1-$week-$round-$level
+ $dry_run rm $backup_tmp_dir/$1-$week-$round-$level
fi
}
diff --git a/lib/beam/postgres.sh b/lib/beam/postgres.sh
index 0eba767..b5a9b6e 100755
--- a/lib/beam/postgres.sh
+++ b/lib/beam/postgres.sh
@@ -45,9 +45,9 @@ postgres_backup() {
logit "backing up PostgreSQL database $database"
test -z "$database" && abend 1 "${1}_database not set"
if [ -z "$dry_run" ]; then
- su postgres -c "pg_dump $verbose $database" > $backup_snapshot_dir/$1-$week-$round-$level
+ su postgres -c "pg_dump $verbose $database" > $backup_tmp_dir/$1-$week-$round-$level
else
- echo "su postgres -c \"pg_dump $verbose $database\" > $backup_snapshot_dir/$1-$week-$round-$level"
+ echo "su postgres -c \"pg_dump $verbose $database\" > $backup_tmp_dir/$1-$week-$round-$level"
fi
if [ $? -ne 0 ]; then
@@ -57,9 +57,9 @@ postgres_backup() {
logit "creating $1-$week-$round-$level.$tar_suffix"
$dry_run tar $verbose $taroptions \
-f $backup_archive_dir/$1-$week-$round-$level.$tar_suffix \
- -C $backup_snapshot_dir $1-$week-$round-$level
+ -C $backup_tmp_dir $1-$week-$round-$level
tarcode $?
- $dry_run rm $backup_snapshot_dir/$1-$week-$round-$level
+ $dry_run rm $backup_tmp_dir/$1-$week-$round-$level
fi
}

Return to:

Send suggestions and report system problems to the System administrator.