LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
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 01-22-2004, 06:40 PM   #1
apoc013
Member
 
Registered: Jan 2004
Location: New York
Distribution: Red Hat 9
Posts: 31

Rep: Reputation: 15
Question Back-up Shell Script


Can anyone point me in the direction of where I can learn to write a simple back-up shell script, that will back-up my system, by creating a tar file with the date and system's name in the title dynamically. And also will compress the archive using the gzip utility.

If by any chance you know of a place I can download an already written script that I can exam, or maybe use that be great to.

Thanks
 
Old 01-22-2004, 07:02 PM   #2
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
There were a bunch of them articles in various forums recently, can't remember if it was here also.
Anyway, here are my notes...

Use current date as backup file name

filename=`date '+%m%d%y'`
tar -cvzf /path/to/destination/${filename}.tar.gz /path/to/source



or like this...

filename=`date '+%m%d%y'`
cd /mnt/linux/folders
tar -cvzf /home/${filename}.tar.gz .
cd /home
 
Old 01-22-2004, 08:25 PM   #3
apoc013
Member
 
Registered: Jan 2004
Location: New York
Distribution: Red Hat 9
Posts: 31

Original Poster
Rep: Reputation: 15
I have done this to generate the filename:

today='date +F'
name='hostname -s'
filename='today_name'

but I can't get the script to run.

I did put #!/bin/sh at the top of the file so that it would be a shell script.

What do I need to get this script to run so that I can test it?
 
Old 01-22-2004, 08:48 PM   #4
homey
Senior Member
 
Registered: Oct 2003
Posts: 3,057

Rep: Reputation: 61
Quote:
I did put #!/bin/sh at the top
That kind uses the command: sh filename sh

I quite often use #!/bin/bash
That uses the command: sh filename

Either way works just as well.
 
Old 01-22-2004, 08:51 PM   #5
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
1. change filename=... to filename=${today}_${name}
2. make sure the file has appropriate execute permissions.
3. when you run the command, either make sure the directory the holds
the file is in your PATH, or use the full path of the command.
 
Old 01-22-2004, 08:53 PM   #6
Berhanie
Senior Member
 
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,625

Rep: Reputation: 165Reputation: 165
also change your quotes to backticks.
 
Old 01-22-2004, 11:27 PM   #7
apoc013
Member
 
Registered: Jan 2004
Location: New York
Distribution: Red Hat 9
Posts: 31

Original Poster
Rep: Reputation: 15
Thanks for all the help!

I got it to work.

 
Old 01-23-2004, 01:40 PM   #8
mary
Member
 
Registered: Sep 2003
Distribution: Gentoo
Posts: 135

Rep: Reputation: 15
I use this script to backup my system to another hd.

http://sourceforge.net/projects/simplebashbu/
 
  


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
Shell script inside shell script treotan Linux - General 4 02-19-2009 06:34 AM
Shell Scripting: Getting a pid and killing it via a shell script topcat Programming 15 10-28-2007 02:14 AM
shell script problem, want to use shell script auto update IP~! singying304 Programming 4 11-29-2005 05:32 PM
[SHELL SCRIPT] Write at the right of the shell window Creak Linux - General 2 04-02-2004 03:00 PM
Help creating a directory back up shell script WarriorWarren Linux - General 6 04-06-2003 09:56 AM

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

All times are GMT -5. The time now is 12:29 AM.

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