ComputerForum.com ComputerForum.com  
TigerDirect
 
Go Back   Computer Forum > Computer Software > Operating Systems

Reply
 
LinkBack Thread Tools Display Modes
Old 08-15-2007, 12:22 PM   #1 (permalink)
Bronze Member
 
Join Date: Jan 2005
Posts: 93
Default Unix Back Up script

Hi All,

This is a question for the more technical script writers out there.

------

I wish to create a script that will simple Back up (tar) a certain directory, and then FTP the tar file to a different box.

------

As simple as that.

Maybe as a little bit to make it smarter would be for it to output to a file to say what time it completed? And perhaps also send an email so to say the back up completed on XXXXX.

This will be a Unix based script, so if anyone has any tips for me, had a look through Google, but they seem to be far more complicating than they should be.
stuaz is offline   Reply With Quote


Old 08-15-2007, 01:48 PM   #2 (permalink)
Diamond Member
 
patrickv's Avatar
 
Join Date: Jul 2006
Location: Soul Chamber
Posts: 5,427
Default

http://www.xs4all.nl/~voorburg/backup.html
__________________
Laptop: Thinkpad X60: Core2Duo T7200 @ 2Ghz,1GB DDR2,110GB SATA -winXP ProSP2
Work Desktop: Core Duo E2180 @ 2Ghz,1.5GB DDR2,240GB HD - XP PRO SP2
Home: Core Duo E2180 2Ghz,1.5GB DDR2,Nvidia GForce 6200TB,320 GB (2x160GB) -Dual boot - XP / OSX 10.5.2
patrickv is offline   Reply With Quote
Old 08-15-2007, 11:15 PM   #3 (permalink)
Diamond Member
 
Camper's Avatar
 
Join Date: Mar 2005
Location: /dev/null
Age: 22
Posts: 1,227
Default

If your coping over a public network you can try to use the scp command to copy the files assuming your copying to a computer with ssh.

http://linux.about.com/od/commands/l/blcmdl1_scp.htm
__________________
Dell Inspiron 530
Q6600 Quad
3gb RAM
Nvidia 8600 GT
500GB HD
Camper is offline   Reply With Quote
Old 08-16-2007, 12:01 AM   #4 (permalink)
VIP Member
 
tlarkin's Avatar
 
Join Date: Apr 2006
Location: Kansas City, MO
Posts: 6,056
Default

okay....

I am no Unix wizard, but I do have a beard. This is a general script you can use that will back up said directory to a network share. then you must set up what is called cron job to automate it to run every night, every week, every month, or whatever frequency you want it to. My method is using rsync but there are other methods out there.

so here it goes, you will need to fill in your blanks to make it work.

Code:
#!/bin/bash

#this script will back up a set directory to a network share

/sbin/rsync -u -a -t /path/to/source/directory /path/to/networkshare

#please note that using the full file path is properly needed for security
#depending on distro rysnc may be installed in a different path
#most likely it lives in /bin, /sbin or /usr/bin, /usr/sbin
#if not sure execute the bash command whereis rysnc to
#find your path

#now we will tell the script to mail the user when finished
#see the man page for the mail command for proper syntax

echo "Back up complete" | mail youremail@yourdomain.com -s back up complete

your back up has been completed

EOF
You may want to mess around with the mail command in terminal, if you type mail user@domain.com it will then prompt you to start typing text. When done just hit period then enter and it will send the mail. Each distro handles syntax different but this script could at least point you in the right direction.

copy/paste it into a plain text file and name it filename.sh then set up a cron job to run it. Of course you want to test it first.
tlarkin is offline   Reply With Quote
Old 08-16-2007, 09:36 PM   #5 (permalink)
VIP Member
 
tlarkin's Avatar
 
Join Date: Apr 2006
Location: Kansas City, MO
Posts: 6,056
Default

ooops I messed up, here is how it should look, remember you will need to plug in your file paths and your settings to make it work

Code:
#!/bin/bash

#this script will back up a set directory to a network share

/sbin/rsync -u -a -t /path/to/source/directory /path/to/networkshare

#please note that using the full file path is properly needed for security
#depending on distro rysnc may be installed in a different path
#most likely it lives in /bin, /sbin or /usr/bin, /usr/sbin
#if not sure execute the bash command whereis rysnc to
#find your path

#now we will tell the script to mail the user when finished
#see the man page for the mail command for proper syntax

echo "Back up complete" | mail youremail@yourdomain.com -s back up complete >> EOF

your back up has been completed

EOF
tlarkin is offline   Reply With Quote


Reply

Thread Tools
Display Modes

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Advanced XP script for start up program. ANNR Operating Systems 0 06-04-2007 01:38 AM
Excelent scripts rejavu Internet Discussion 0 12-17-2006 10:52 PM
need advice on getting or making a script tlarkin Computer Networking and Servers 3 08-03-2006 09:45 PM
Thdd Is Back MONKEY BOY Internet Discussion 6 06-23-2006 02:04 PM
2 Fans Back To Back... bcomatts Computer Cases, Power Supplies and Cooling 3 11-27-2005 04:28 AM


All times are GMT +1. The time now is 04:00 PM.


Powered by: vBulletin Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Copyright © 2002-2007 Computer Forum and Web Design Forum