Visit Our UNIX and Linux User Community


Help with Backup Shell Script

 
Thread Tools Search this Thread
Homework and Emergencies Homework & Coursework Questions Help with Backup Shell Script
# 1  
Old 03-28-2011
Help with Backup Shell Script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted!

1. The problem statement, all variables and given/known data:

Create a script that will backup all important system files every Friday night and send an email to the administrator stating if the backup was successful or not.


2. Relevant commands, code, scripts, algorithms:

if/then statement
cp /home /ect /usr /local /opt /var /root /boot
cron job or at command
mail -s 'subject'

3. The attempts at a solution (include all code and scripts):

Commands listed above but I have not put them all together until I'm sure that I have all the correct commands.

4. Complete Name of School (University), City (State), Country, Name of Professor, and Course Number (Link to Course):

Devry University, Decatur, GA, USA, Professor:Bogoevski, Netw240/ACC_A


Note: Without school/professor/course information, you will be banned if you post here! You must complete the entire template (not just parts of it).
# 2  
Old 03-29-2011
First you need a destination for the backups. Let's say it is /backup. It says "important files" and to me that means you pick and choose. For example, out of /etc, maybe passwd, shadow, group, and hosts. There are probably others but all of /etc sounds excessive. Any of /opt also sounds excessive to me. Once the script is working you can tweak the exact file list. Also the exact list will vary from OS to OS and you haven't told us yours.

So it sounds like you cd to /backup, create etc, cd to /backup/etc and copy the files you pick from etc. And repeat this for other directories that have file that you feel are important. cp has an exit status and you will need to check it to see if the cp was successful.

The script should be run out of cron.

I think that this should give you enough ideas to start your script.
# 3  
Old 03-29-2011
I only want to backup files that I would need to restore the system if it went down. The system that would be used is Zorin os4. I am not sure how to break that down further, I know it has something to do with Ubuntu (as you can tell, I am brand new to Linux and don't know very much). In doing my research I learned the TAR commmand will backup only important system files, below is the command; is there anything I would need to change?

tar cvpzf backup.tgz --exclude=/proc --exclude=/lost+found --exclude=/backup.tgz --exclude=/mnt --exclude=/sys /

Last edited by kjmpa26; 03-29-2011 at 07:20 PM..
# 4  
Old 03-29-2011
A tar archive is a better way to go. I wasn't sure if you had encountered tar yet so I didn't mention it. Your backup file, backup.tgz, is going to be created in the current directory. So you need to cd to destination directory first. It is going to be a very large file. Make sure you have plenty of free space in the destination. You are backing up pretty much everything.

You should make sure that you exclude the directory containing backup.tgz. You show an exclude for /backup.tgz. That implies that you plan to put the backup file in the root directory. We usually would put it elsewhere.
# 5  
Old 03-30-2011
Why not use rsync to do your backup ? and you can compress it in a single directory ..
# 6  
Old 04-03-2011
This is what I have so far, but I am still unsure.


1.First, install your cron job by running the following command

Code:
# crontab -e
 
0 10 * * 5 tar -cvpzf backup.tar.gz --exclude=/backup.tar.gz --exclude=/proc --exclude=/lost+found --exclude=/sys --exclude=/mnt --exclude=/media --exclude=/dev / 
| mail -s 'System Backup was Successful' myname.hotmail.com 
else
mail -s 'System Backup was Non-Successful' myname.hotmail.com

Moderator's Comments:
Mod Comment Please use [CODE] tags instead of funky coloring for readability

Last edited by kjmpa26; 04-05-2011 at 12:11 PM..
# 7  
Old 04-05-2011
Can anyone steer me in the right direction?

Previous Thread | Next Thread
Test Your Knowledge in Computers #237
Difficulty: Easy
Paul Baran was the first to build a theoretical model for communication using packet switching.
True or False?

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help with Backup Shell Script

Dear friends, I need your help. I need to create a bash script which can loop through $source_dir once a month, and find the backup of the last day of a given month for each of the 2 file types, as can be seen below. Assume that source_dir="/backup/daily" Assume that... (1 Reply)
Discussion started by: joemb
1 Replies

2. Shell Programming and Scripting

Shell script to call Oracle archive backup script when file system reaches threshold value

Hello All, I need immediate help in creating shell script to call archivebkup.ksh script when archive file system capacity reaches threshold value or 60% Need to identify the unique file system that reaches threshold value. ex: capacity ... (4 Replies)
Discussion started by: sasikanthdba
4 Replies

3. Shell Programming and Scripting

Help with Backup Shell Script

Hello guys. I am a Brazilian, I use a linux machine, to access it using the program Putty. I own a GTA Multiplayer, I have a folder on my server named accounts, there is the account of all players. Each player has their own file, the files are saved as follows: PlayerName.ini I would... (4 Replies)
Discussion started by: JimCarrey
4 Replies

4. Shell Programming and Scripting

Help with Backup Shell Script

i need to print the first date of the previous month in 20130101 format. i use the below script month_year=$(date +'%m%Y' | awk '!--$1{$1=12;$2--}') m=${month_year% *} y=$month_year##* } d=$(cal $m $y | paste -s - | awk '{print $NF}') firstdate=${printf '02d01%s' $y $m) echo $firstdate ... (1 Reply)
Discussion started by: vino1989
1 Replies

5. Shell Programming and Scripting

Help with Backup Shell Script for Network Device Configuration backup

HI all, im new to shell scripting. need your guidence for my script. i wrote one script and is attached here Im explaining the requirement of script. AIM: Shell script to run automatically as per scheduled and backup few network devices configurations. Script will contain a set of commands... (4 Replies)
Discussion started by: saichand1985
4 Replies

6. Shell Programming and Scripting

shell script to backup

Q: script to daily backup all databases in the server, retain only last 4 backps please anyone give me a reply (3 Replies)
Discussion started by: pssooraj72
3 Replies

7. Shell Programming and Scripting

Help with backup shell script

Hello, Need help with a script to backup a configuration file BSD Save the file / Firewall / ConfigFiles to a remote ftp server here is the script # / bin / sh Date = $ (date +% d-% Y-% m-H-M) tar-cvf ConfigFiles.tar / Firewall / ConfigFiles ConfigFiles.tar mv / Firewall-$... (11 Replies)
Discussion started by: telouet
11 Replies

8. Shell Programming and Scripting

Help with backup shell script

Hello all, I am trying to backup my system database and root filesystem on remote server that is mounted on my system using tar command. For the database, i use (cd /database; tar cvf file.tar .) for the Root filesystem, i use (cd /; tar uEvf file.tar .) both are to be backup on the same... (1 Reply)
Discussion started by: Omoniyi
1 Replies

9. Shell Programming and Scripting

Need help with a backup shell script

am writing my very first shell script and need some assistance. What I need help on is three things in particular. 1) Do I need to use the sleep function after the tar command or does the script know to wait until tar finishes to move on to the next line? 2) Did I populate the variable DATE... (4 Replies)
Discussion started by: rhm54
4 Replies

10. UNIX for Dummies Questions & Answers

Help with a backup shell script

I'm having an issue with a problem A problem with this backup script is that if you backup the same file twice, you may get a warning message because you're overwriting an existing file. You could suppress the warning message, but a better solution is to save a series of backups distinguished by... (1 Reply)
Discussion started by: Dingosatemypant
1 Replies

Featured Tech Videos