LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-25-2012, 11:10 AM   #1
mogleyzw
LQ Newbie
 
Registered: May 2012
Posts: 8

Rep: Reputation: Disabled
Backup Script error


Hi,

I am trying to write a backup script but keep getting an error. Here is my code

Code:
#!/bin.bash

backup_files=/home
backup_dir=/backup
date=$(date +%d-%m-%Y)
archive_files="$date.tgz"

mkdir backup

echo "backing up $backup_files to $archive_files"

tar czvf $backup_dir/$archive_files $backup_files

echo "backup complete"
After I run the program I get the following messeges.

Quote:
/home/
: No such file or directory
tar: /home/user/
/home/user/.bash_history
Error not recoverable: exiting now
/home/user/backup.sh
I am using a virtual device with ubuntu running and there but there is nothing on it. Is that why I am getting that error??

Thanks in advance.
 
Old 05-25-2012, 11:28 AM   #2
mogleyzw
LQ Newbie
 
Registered: May 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
I just realized this is in the wrong place, sorry.
 
Old 05-25-2012, 11:30 AM   #3
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,348

Rep: Reputation: Disabled
Quote:
Originally Posted by mogleyzw View Post
Hi,

I am trying to write a backup script but keep getting an error. Here is my code

Code:
#!/bin.bash

backup_files=/home
backup_dir=/backup
date=$(date +%d-%m-%Y)
archive_files="$date.tgz"
OK, at this point $backup_files is "/home", $backup_dir is "/backup" and $archive_files is "25-05-2012.tgz". Then you proceed to do:
Quote:
Originally Posted by mogleyzw View Post
Code:
mkdir backup
Unless the current directory is /, the above does nothing useful.
Quote:
Originally Posted by mogleyzw View Post
Code:
echo "backing up $backup_files to $archive_files"

tar czvf $backup_dir/$archive_files $backup_files

echo "backup complete"
You're running tar czvf /backup/25-05-2012.tgz /home, which result in:
Code:
/home/
: No such file or directory
tar: /home/user/
/home/user/.bash_history
Error not recoverable: exiting now
/home/user/backup.sh
The "Error not recoverable" message is the real problem, and my guess is it appears because the directory /backup doesn't exist.
 
Old 05-25-2012, 11:45 AM   #4
mogleyzw
LQ Newbie
 
Registered: May 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Thanks for that I kind of get what you mean.

How would I change it so it backs up the "/home" directory.
 
Old 05-25-2012, 11:55 AM   #5
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,348

Rep: Reputation: Disabled
All I did was add the missing slash to "mkdir /backup" (or even better, "mkdir $backup_dir", since you're already using a variable to hold the directory name).
 
Old 05-25-2012, 12:01 PM   #6
mogleyzw
LQ Newbie
 
Registered: May 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Wow thank you that worked
 
Old 05-25-2012, 12:08 PM   #7
mogleyzw
LQ Newbie
 
Registered: May 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Sorry one last thing, when I tested it, it work but I can not find where the backup is. I was under the impression it would go into the folder backup with the date as the file name.
 
Old 05-25-2012, 12:18 PM   #8
mogleyzw
LQ Newbie
 
Registered: May 2012
Posts: 8

Original Poster
Rep: Reputation: Disabled
Don't worry found it "ls -l /backup/"

Thanks for all the help.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
[Backup Script] syntax error near unexpected token `else' Cr0nixx Programming 12 09-27-2011 01:37 PM
Strange error messages on backup script ahwm Linux - Server 3 09-20-2010 11:47 AM
[SOLVED] tar backup script error! windstory Linux - Newbie 4 11-02-2009 01:52 AM
error in a backup script adam_blackice Programming 6 08-25-2007 04:30 PM
error in backup script, deleted almost all data :( ash4stuff Linux - Software 0 06-11-2004 06:58 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 07:57 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