Disallow non-level-0 backups and /etc/dumpdates for non-filesystem roots

This commit is contained in:
Jamie Cameron
2008-04-19 22:41:47 +00:00
parent 39b67ba4f1
commit fd406331b5
7 changed files with 30 additions and 16 deletions

View File

@@ -34,3 +34,4 @@ Fixed remote tar backups via FTP on OSX.
Files and directories to exclude can be specified for TAR format backups on Linux.
---- Changes since 1.410 ----
Added checkboxes to control if failure of the pre and post-backup commands cause the whole job to be regarded as a failure.
Prevent non-level-0 backups and updating of the /etc/dumpdates file for backups of directories that are not filesystem mount points, as this isn't supported by the <tt>dump</tt> command.

View File

@@ -68,8 +68,8 @@ unlink("$module_config_directory/$_[0]->{'id'}.dump");
sub directory_filesystem
{
local $fs;
foreach $m (sort { length($a->[0]) <=> length($b->[0]) }
&foreign_call("mount", "list_mounted")) {
foreach my $m (sort { length($a->[0]) <=> length($b->[0]) }
&mount::list_mounted()) {
local $l = length($m->[0]);
if ($m->[0] eq $_[0] || $m->[0] eq "/" ||
(length($_[0]) >= $l && substr($_[0], 0, $l+1) eq $m->[0]."/")) {
@@ -79,6 +79,17 @@ foreach $m (sort { length($a->[0]) <=> length($b->[0]) }
return wantarray ? @$fs : $fs->[2];
}
# is_mount_point(dir)
# Returns 1 if some directory is a filesystem mount point
sub is_mount_point
{
local ($dir) = @_;
foreach my $m (&mount::list_mounted()) {
return 1 if ($m->[0] eq $dir);
}
return 0;
}
# same_filesystem(fs1, fs2)
# Returns 1 if type filesystem types are the same
sub same_filesystem

View File

@@ -5,5 +5,8 @@ is chosen, every file under the directory to backup will be saved. Otherwise,
only files that are new or modified since the last dump of a lower level will
be written. <p>
When backing up a directory that is not a filesystem mount point, the only
level that can be selected in 0. <p>
<hr>

View File

@@ -1,7 +1,6 @@
<header>Update /etc/dumpdates file?</header>
When this option is enabled, the date, time, source and destination of the backup
will be recorded in human-readable form in <tt>/etc/dumpdates</tt>. <p>
This option can only be enabled when backing up an entire filesystem. When enabled, the source filesystem device name, level, date and time of the backup will be recorded in human-readable form in <tt>/etc/dumpdates</tt>. There may be only one entry per filesystem at each level. This option is useful when using the <tt>dump -W</tt> command-line option to display the most recent dump date and level of each filesystem.<p>
<hr>

View File

@@ -166,11 +166,7 @@ else {
if ($_[0]->{'fs'} eq 'xfs') {
# Parse xfs options
local $mp;
foreach $m (&foreign_call("mount", "list_mounted")) {
$mp++ if ($m->[0] eq $in{'dir'});
}
$mp || &error($text{'dump_emp'});
&is_mount_point($in{'dir'}) || &error($text{'dump_emp'});
$in{'label'} =~ /^\S*$/ && length($in{'label'}) < 256 ||
&error($text{'dump_elabel2'});
$_[0]->{'label'} = $in{'label'};

View File

@@ -33,7 +33,7 @@ dump_dest=Backup to
dump_file=File or tape device
dump_host=Host $1 as user $2 in file or device $3
dump_level=Dump level
dump_level_0=(Full backup)
dump_level_0=0 (Full backup)
dump_label=Backup label
dump_multi=Split across multiple files?
dump_update=Update <tt>/etc/dumpdates</tt> file?
@@ -102,6 +102,8 @@ dump_ermt=Missing or invalid path to <tt>rmt</tt> program
dump_reverify=Attempt test restore after backup to verify?
dump_remount=Remount with <tt>noatime</tt> option during backup?
dump_eftpupdate=Adding files to an existing archive is not possible when using FTP.
dump_eleveldir=Only level 0 backups are allowed for directories that are not filesystem mount points
dump_eupdatedir=The <tt>/etc/dumpdates</tt> file can only be updated for directories that are filesystem mount points
edit_err=Failed to create backup
edit_edir=Missing backup directory

View File

@@ -259,11 +259,7 @@ if ($_[0]->{'fs'} eq 'tar') {
}
elsif ($_[0]->{'fs'} eq 'xfs') {
# Parse xfs options
local $mp;
foreach $m (&foreign_call("mount", "list_mounted")) {
$mp++ if ($m->[0] eq $in{'dir'});
}
$mp || &error($text{'dump_emp'});
&is_mount_point($in{'dir'}) || &error($text{'dump_emp'});
$in{'label'} =~ /^\S*$/ && length($in{'label'}) < 256 ||
&error($text{'dump_elabel2'});
$_[0]->{'label'} = $in{'label'};
@@ -289,11 +285,17 @@ elsif ($_[0]->{'fs'} eq 'xfs') {
}
}
else {
# Parse ext2/3 options
# Parse ext2/3 dump options
$_[0]->{'rsh'} = &rsh_command_parse("rsh_def", "rsh");
$_[0]->{'pass'} = $in{'pass'};
if ($in{'update'}) {
&is_mount_point($in{'dir'}) || &error($text{'dump_eupdatedir'});
}
$_[0]->{'update'} = $in{'update'};
$_[0]->{'multi'} = $in{'multi'};
if ($in{'level'} > 0) {
&is_mount_point($in{'dir'}) || &error($text{'dump_eleveldir'});
}
$_[0]->{'level'} = $in{'level'};
$in{'label'} =~ /^\S*$/ && length($in{'label'}) < 16 ||
&error($text{'dump_elabel'});