[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Script does not do what it is told to do



On 24/10/2019 23:37, Ken Heard wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Whenever I run this script -- or several others like it

#!/bin/bash
# Script to back up all browser files in directory /home/ken/mozilla.
STARTDIR=$PWD
cd /home/ken
tar -czf /media/fde/backups/kbrowsers.tgz  --exclude-caches \
- --wildcards -T docs/tarlists/kbrowsers.lst
cd "$STARTDIR"

it returns the following:

ken@Turing:~$ tarkbrowsers
tar (child): /media/ssda/backups/kbrowsers.tgz: Cannot open: No such
file or directory
tar (child): Error is not recoverable: exiting now
tar: /media/ssda/backups/kbrowsers.tgz: Cannot write: Broken pipe
tar: Child returned status 2
tar: Error is not recoverable: exiting now

It is trying to save the tarball to a different portable storage
device, ssda, which had failed and consequently is no longer in
/etc/fstab.  How could such a thing happen?

There is nothing inherently wrong with the script, in that it would work if all other things were equal, but they are clearly not.

Do an 'ls -l' on '/media/fde/backups', does it reveal anything? It might well do.

Using the -C option to tar is preferable to the way you are doing it.  So,

tar -czf /media/fde/backups/kbrowsers.tgz --exclude-caches --wildcards -C /home/ken
 -T ./docs/tarlists/kbrowsers.lst

might be better. You  will return to your starting location then, without the need for STARTDIR gubbings.

Mike.

--



Reply to: