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 |
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 |
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? |
Quote:
I quite often use #!/bin/bash That uses the command: sh filename Either way works just as well. :) |
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. |
also change your quotes to backticks.
|
Thanks for all the help!
I got it to work. :D |
|
All times are GMT -5. The time now is 12:56 AM. |