|
Author: Erin
Date: 06-08-04 16:28
This simple script uses "dump" to backup a hard drive to another hard drive. It will do a full backup on Sunday and an incremental every other day of the week. All this and it runs the dump file through gzip to compress it.
-----------------------------
#!/usr/bin/perl -w
use strict;
my @FS = ('/', '/home', '/tmp', '/usr', '/var');
my $day = &day;
my $type;
if ($day eq "sunday") {
$type = "0"
} else {
$type = "1"
}
foreach (@FS) {
my $name = $_;
if ($name eq '/') {
$name = '/root';
}
$name =~ s|^/||g;
system("/sbin/dump -$type -auf - $_ | gzip -q > /backup/$day/$name.dump.gz");
}
sub day {
my @days = ('sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday');
my (undef, undef, undef, undef, undef, undef, $wday, undef, undef) = localtime(time);
return("$days[$wday]");
};
exit(1);
|
|
Reply To This Message
|
|
Author: Jeroen Steggink
Date: 17-09-04 12:59
Hi,
I tried this script, but I get the following error.
DUMP: Date of this level 1 dump: Fri Sep 17 14:51:29 2004
DUMP: Date of last level 0 dump: the epoch
DUMP: Dumping /dev/ad0s1a (/) to standard output
DUMP: mapping (Pass I) [regular files]
DUMP: mapping (Pass II) [directories]
DUMP: estimated 60355 tape blocks.
DUMP: dumping (Pass III) [directories]
DUMP: dumping (Pass IV) [regular files]
DUMP: DUMP: 61394 tape blocks
DUMP: finished in 11 seconds, throughput 5581 KBytes/sec
DUMP: level 1 dump on Fri Sep 17 14:51:29 2004
DUMP: DUMP IS DONE
DUMP: SIGSEGV: ABORTING!
Segmentation fault (core dumped)
When I do this:
/sbin/dump -1 -auf - /var | gzip -q > /mnt/drive2/backup/friday/var.dump.gz
it al works fine. It just stops after the first dump.
|
|
Reply To This Message
|
|
Author: Erin
Date: 17-09-04 21:09
Some updates. I wrote the first version years ago.
#!/usr/bin/perl
# Part of a group of programs to admin a FreeBSD web/email server.
# Do what you want with it, just keep the copyright.
#
# Copyright 2004, Erin Fortenberry
#
# $Id: backup.pl,v 1.2 2004/08/26 21:01:19 erinf Exp $
#
# usage: "scriptname -h"
#
# I use /backup as my backup drive and it is nfs mounted.
# You can remove the compression on this, but it adds alot
# to the backup time so I did not make a switch for it.
#
# The current backup directory it /backup/$hostname/$day.$name.dump.gz
#
# This script does not check to see if the backup directories exist or
# if they have enough space for the dump file.
#
# Requires perl 5.6.1 or newer.
#
use strict;
use warnings;
use Getopt::Std;
use POSIX qw(strftime);
use vars qw($VERSION);
$Getopt::Std::STANDARD_HELP_VERSION = 1;
$VERSION = '1.2';
my @FS = ('/', '/home', '/usr', '/var');
my $day = lc(strftime "%A", localtime);
my $hostname = `/bin/hostname -s`;
my %opt = ('F' => 0, 'd' => 0, 'h' => 0);
my $type;
chomp $hostname;
getopts("Fdh",\%opt);
if ( $opt{h} == 1 ) {
print STDERR << "EOF";
usage: $0 [-hqd]
-h : this (help) message
-d : Dry run, only print what I am going to do
-F : Force full backup {type 0}
example: $0 -h -q -d
EOF
exit(0)
}
if ( $opt{F} == 1 ) {
$type = "0"
} else {
if ($day eq "sunday") {
$type = "0"
} else {
$type = "1"
}
}
foreach (@FS) {
my $name = $_;
if ($name eq '/') {
$name = '/root';
};
$name =~ s/^\///g;
# Unncomment for /backup/$day/$name.dump.gz
# my $command = '/sbin/dump -' . $type . ' -auf - ' . $_ . ' | gzip -q > /backup/' . $day . '/' . $name . '.dump.gz';
# Put a "#" in front of the next line if you uncomment the last line
my $command = '/sbin/dump -' . $type . ' -auf - ' . $_ . ' | gzip -q > /backup/' . $hostname . '/' . $day . '.' . $name . '.dump.gz';
if ($opt{d}) {
print($command . "\n");
} else {
system($command);
};
};
exit(0);
|
|
Reply To This Message
|
|