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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
01-22-2004, 06:40 PM
|
#1
|
|
Member
Registered: Jan 2004
Location: New York
Distribution: Red Hat 9
Posts: 31
Rep:
|
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
|
|
|
|
01-22-2004, 07:02 PM
|
#2
|
|
Senior Member
Registered: Oct 2003
Posts: 3,057
Rep:
|
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
|
|
|
|
01-22-2004, 08:25 PM
|
#3
|
|
Member
Registered: Jan 2004
Location: New York
Distribution: Red Hat 9
Posts: 31
Original Poster
Rep:
|
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?
|
|
|
|
01-22-2004, 08:48 PM
|
#4
|
|
Senior Member
Registered: Oct 2003
Posts: 3,057
Rep:
|
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. 
|
|
|
|
01-22-2004, 08:51 PM
|
#5
|
|
Senior Member
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,560
Rep: 
|
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.
|
|
|
|
01-22-2004, 08:53 PM
|
#6
|
|
Senior Member
Registered: Dec 2003
Location: phnom penh
Distribution: Fedora
Posts: 1,560
Rep: 
|
also change your quotes to backticks.
|
|
|
|
01-22-2004, 11:27 PM
|
#7
|
|
Member
Registered: Jan 2004
Location: New York
Distribution: Red Hat 9
Posts: 31
Original Poster
Rep:
|
Thanks for all the help!
I got it to work.

|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:56 AM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|