LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 06-30-2011, 07:27 AM   #1
ramecare
Member
 
Registered: Feb 2011
Posts: 179

Rep: Reputation: 0
tar backup shell script


Dear All,

The below shell script is mounting a drive and taking tar backup with today's date and sending status of log to particular directory & sending mail automatically,when i run the below shell script iam reciving the below error, i tired to solve but i was not able to solve,can any one help to solve the problem.

SHELL SCRIPT:
#!/bin/bash
mount -t cifs //10.200.1.125/servers/$(hostname) temp -o username=harish,password=ecare2@
date=`/bin/date "+%Y.%m.%d.%H.%M.%S"`
tar -cvf temp/$date.tar /backup
echo "Backup taken">>/var/log/$date
mail -s $date ramkannan_88@yahoo.com <<EOF
Backup completed successfully

ERROR:
[root@itsupport Desktop]# ./daily-backup
mount error: can not change directory into mount target temp
tar: temp/2011.06.30.17.37.05.tar: Cannot open: No such file or directory
tar: Error is not recoverable: exiting now

Thanks,
 
Old 06-30-2011, 07:38 AM   #2
Skaperen
Senior Member
 
Registered: May 2009
Location: center of singularity
Distribution: Xubuntu, Ubuntu, Slackware, Amazon Linux, OpenBSD, LFS (on Sparc_32 and i386)
Posts: 2,681
Blog Entries: 31

Rep: Reputation: 176Reputation: 176
You might want to give the full path to "temp" (your mount point). Also, be sure it has permissions to allow you to mount it, both for the directory, and if this is not root, in /etc/fstab.

You can append the string " || exit 1" at the end of a command to make a script exit immediately on failure (so that subsequent commands don't create a possible mess). If the command is a pipeline, read about variable PIPESTATUS in the bash man page for how to detect errors there.
 
Old 07-01-2011, 06:18 AM   #3
ramecare
Member
 
Registered: Feb 2011
Posts: 179

Original Poster
Rep: Reputation: 0
Yes,u r right,when i give the full path its working,Thank u for the solution.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
BASH: Tar Backup Script worm5252 Programming 8 02-03-2010 12:27 PM
[SOLVED] tar backup script error! windstory Linux - Newbie 4 11-02-2009 01:52 AM
[SOLVED] tar backup Bash script help speedhunt3r Linux - General 4 10-27-2009 03:08 AM
Basic backup script using Tar GraemeK Linux - General 1 09-17-2004 05:19 AM
Backup script to tar untoldone Programming 2 05-20-2004 03:03 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 07:31 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration