LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Back-up Shell Script (https://www.linuxquestions.org/questions/linux-newbie-8/back-up-shell-script-137617/)

apoc013 01-22-2004 06:40 PM

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

homey 01-22-2004 07:02 PM

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

apoc013 01-22-2004 08:25 PM

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?

homey 01-22-2004 08:48 PM

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. :)

Berhanie 01-22-2004 08:51 PM

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.

Berhanie 01-22-2004 08:53 PM

also change your quotes to backticks.

apoc013 01-22-2004 11:27 PM

Thanks for all the help!

I got it to work.

:D

mary 01-23-2004 01:40 PM

I use this script to backup my system to another hd.

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


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