Gentoo Archives: gentoo-server

From: Paul Court <emails@××××××××××××.uk>
To: gentoo-server@l.g.o
Subject: Re: [gentoo-server] backup and crontab problem
Date: Tue, 21 Sep 2004 11:08:19
Message-Id: 862915AD-0BBE-11D9-A416-000A95CC805E@paulcourt.co.uk
In Reply to: [gentoo-server] backup and crontab problem by "Frank Nørvig"
1 I can only offer some more obvious ideas, but I often find these are the
2 answers to my problems... Maybe I am just a noobie! :)
3
4 1.) Would it be worth running "mt -f /dev/nst0 stat" to check the status
5 of the tape before you run the tar command.
6 2.) Have you run the script a few times from the command line to check
7 it's not an alternating problem. eg only every second run works.
8 3.) Is the cron environment the same as the login one - its quite
9 different on my system, but I am not sure how env vars would come into
10 play for this script?
11
12 Just some ideas for ya.
13
14 Paul
15
16
17 On 21 Sep 2004, at 08:39, Frank Nørvig wrote:
18
19 > Hi there,
20 >
21 > I'm making a tape backup-script that looks like this:
22 >
23 > #!/usr/bin/perl -w
24 > WriteLog("Loading tape...");
25 > $exec = `mtx -f /dev/sg0 first 2>&1`;
26 > if ($exec) { WriteLog($exec); }
27 >
28 > WriteLog("Rewinding tape...");
29 > $exec = `mt -f /dev/nst0 rewind 2>&1`;
30 > if ($exec) { WriteLog($exec); }
31 >
32 > WriteLog("Backing up data...");
33 > $exec = `tar -c -p --exclude-from=/opt/backup/backup-exclude.txt -M
34 > -F /opt/backup/changetape.pl -f /dev/nst0 /var/data 2>&1`;
35 > if ($exec) { WriteLog($exec); }
36 >
37 > ... (rest is not important)
38 >
39 > When running this script from bash it works like a charm. All data
40 > from /var/data is backed up onto tape and everyone is happy.
41 >
42 > BUT when I put the script into my cronjob for automatic start in the
43 > night, it fails with following error:
44 >
45 > [2004-09-21 05:43:58] Loading tape...
46 > [2004-09-21 05:43:58] Rewinding tape...
47 > [2004-09-21 05:44:58] Backing up data...
48 > [2004-09-21 05:46:59] tar: /dev/nst0: Cannot open: Input/output error
49 > tar: Error is not recoverable: exiting now
50 >
51 > Why is this happening? And why is it only happening when run from the
52 > cronjob? Nothing else is run and no other program is using the
53 > tape-robot. The two tape-commands (mt and mtx) runs smoothly and loads
54 > + rewinds the tape but the tar command fails everytime and has for
55 > over a month now. Every morning I have to run the script manually from
56 > bash and it runs perfectly then.
57 >
58 > I'm not new to Linux (or Gentoo) and has been installing and
59 > maintaining servers for more than 4 years now but this problem is a
60 > killer :(
61 >
62 > Frank Nørvig
63 >