LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices

Reply
 
Search this Thread
Old 04-25-2005, 03:21 AM   #1
ahmed4linux
LQ Newbie
 
Registered: Aug 2004
Posts: 23

Rep: Reputation: 15
Lightbulb small-article-backup


hi ,
folks i am writting this coz it may be help full to any new guy.

the purpose of this script is to tar the required files and ftp them to any remote location.

it is tested on rh9 platform, as dont have any other.

_____________________________________________________
#!/bin/sh
DATE=`date +%F` ###this will set current date to DATE value
echo " so the file is present we will tar all important files"
echo " the important files is user information and group imformation"
echo " user home directories"
echo " users mails /var/spool/directory"
############
#### now creating real back up
###########
tar -cvf "$DATE.tar" "/etc/hosts" "/var/spool/mail" "/etc/resolv.conf" ### creates DATE.tar file
tar -vrf "$DATE.tar" "/etc/passwd" "/etc/shadow" "/etc/group" "/var/www" ## append to files
tar -vrf "$DATE.tar" "/etc/httpd/conf/httpd.conf" "/var/named" "/etc/named.conf"
##### YOU can also check if the DATE.tar file was created or not ###########
### DATE.tar file will be u r current date eg:- 2005-04-25.tar ###########
##### u can also gzip it if u want to compress it ######
echo "Now we will ftp the created backup File"
ftp -n <Hostname or IP address/ of FTP server> <<abcdef
user <username> <password>
ls #### it optional i am checking and changing directory on
cd back ### ftp server
bin ### switching to binary format
hash #### enabling hash printing
put "$DATE.tar" ### uploading u r backup tar file
bye #### logging out of ftp server
abcdef
exit 0 ### end of script
_______________________________________
this was very scrapy but working script....
later it can also be added to crontab entry for automation.
set all executable permissions to script
suppose our script is backup.sh at /var/back/
chmod +x /var/back/backup.sh ##command to set executable permission on file
____________________
just type at console it will open a text editor usually i work with vi
crontab -e
_________
now in that open editor type
30 2 * * 1,3,5,7 /var/back/backup.sh ####eg :- /var/back/back.sh -> pacth to file

now save and close
___________________________
this will execute u r back up script every monday, wed,friday, sunday at night 2:30
______________________________________________

now if any one want to modify or add or beautify this u can surely do it.
thanks in advance.

__________________
Ahmed Mohiuddin
ms_dream@rediffmail.com
 
Old 04-27-2005, 10:40 AM   #2
Technoslave
Member
 
Registered: Dec 2003
Location: Northern VA
Posts: 493

Rep: Reputation: 30
Not bad, but as a suggestion, you'd be better off using ssh/scp, or even better rsync.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help in understand an article benedict Linux - Newbie 1 08-12-2004 01:10 PM
Openldap with small directory very small iholdap Linux - Networking 5 10-04-2003 08:09 AM
3 small problems in 1 small post vzzt! Linux - Software 10 02-27-2003 07:40 PM
Slackware Article figadiablo Slackware 7 10-10-2002 09:42 AM
rh article tundra Linux - General 10 06-24-2002 12:05 AM


All times are GMT -5. The time now is 12:40 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration