Re: Bash script questions.



Longfellow said "Bash script questions."
I've got rsync backing the partitions of one drive to another, and they
all work find. Now I want a shell script to run all the backups.

I began with mount checks:

if [ ! -d {some directory in backup partition} ]; then
mount -t ext2 {backup partition} /mnt/{backup mount}
fi

for each backup partition.

Then I list all the backup scripts with sleep 60 between each to let
things cool down a bit.

1) In each backup script: I've yet to trust the backup log to record
any error messages because I don't know whether or not '2>&1' works with
'>>' (append). I gather that the '2>&1' should be at the end of the
command rather than following or preceeding the append operator. Does
this work with append, and if so, where should it be?

Sounds like your doing it right

${COMMAND} 1>&2 ${LOGFILE} # Is at the end of the command.

If you want to record the error code then put

echo $? >> ${LOGFILE}

I'm going to trust that someone else will either back me up or tell me
I'm talking crap. I'm tired tonight.

2) In the master script, I want each backup script to be able to write
any problems to the log file. I gather that rsync gracefully exits with
an error message in any case, but I'm not certain. I don't want each
script to depend on the success of the previous one, so I'm not using
'&&' between scripts. What, if anything, should follow the script
executable?

$? == ${ERRMSG}

`man bash` for more info. $? is a wonderful thing, use liberally.

If all this gets to work dependably, it will become a cron job, so I
won't be around to intervene if things screw up.

Then look to making a quick and dirty e-mail script to mail off the log
files to you. In Slack I use `mail` from the Nail package. Most distros
have a `mail` command IME.

--
This signature intentionally left blank

http://www.websterscafe.com
.



Relevant Pages

  • Feedback on backup script
    ... The one problem I have is that the script keeps stopping at lines 633,635 and or 637 with the error "Path Not Found" I have emailed the original author for help but haven't heard back yet. ... I was just wondering if the problem could be that the account running the script doesn't have correct permissions to a share/directory/file that it's trying to backup? ... ' always one less than the actual number of folders. ... ' Show the user free space info on all available disk drives ...
    (microsoft.public.scripting.vbscript)
  • Re: Enterprise Manager Newbie Question
    ... a SQL backup is not a simple copy of the database files. ... Is it possible to write a script that one could run from a workstation and ...
    (microsoft.public.sqlserver.tools)
  • Re: xcopy and vbscript
    ... It takes about 5-6 minutes to backup approximately ... A copy of the script is below for reference. ... ObjShell.Popup strMessage, 5, "Backup Complete", OK_Button ... Dim sSrc, sDest ' as string ...
    (microsoft.public.scripting.vbscript)
  • Re: How do I move an account... A few more details... and more
    ... >> use this system as a backup system if the first ever goes down. ... >> rsync for this. ... >serv1 and the system you back up to is fs. ... >rsync script. ...
    (Fedora)
  • Re: Maintain backup directory
    ... When I run the script (after setting target to the right ... the backup media runs out of ... Remove the word "echo" from Line #18 to enable the file deletion. ...
    (microsoft.public.scripting.wsh)