LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-29-2006, 04:05 AM   #1
venki
Member
 
Registered: Sep 2006
Location: India
Distribution: suse10.2
Posts: 128

Rep: Reputation: 15
code for backup automatically


hi ,

i want to take the back up of my directory .

it should be automatically done!!

say i have folder in /home/nagesh/data

this data should be automatically stored in another file-system for every 5 min it has to check and that data shld be in file=system

plz help me

give the shell script for that since i am new to this.

thanking you,
Nagesh
 
Old 09-29-2006, 04:27 AM   #2
Wim Sturkenboom
Senior Member
 
Registered: Jan 2005
Location: Roodepoort, South Africa
Distribution: Ubuntu 12.04, Antix19.3
Posts: 3,794

Rep: Reputation: 282Reputation: 282Reputation: 282
have a look at man cp (look for -r option) for the copy
have a look at man crontab for the automatic stuff
 
Old 09-29-2006, 05:22 AM   #3
shawnbishop
Member
 
Registered: Dec 2005
Location: South Africa
Distribution: CentOS,Ubuntu,Fedora
Posts: 249

Rep: Reputation: 30
Good Day

First of all do want this backup to be "live"?, that is as the files change in Directory 1, it must change in Directory 2?if so do as follows
Well of course you need to write a script eg: backup.sh, place this in it

#!/bin/bash
#
# Script to backup files using Rsync

## The following syncs files between two directories, as you can see change the ##file paths

rsync -azrpog --delete /files/to/backup /destination/of/backup

## End of Script

Close your text editor and make sure the file is executable by doing the following

$ chmod 755 backup.sh

Then add to the Crontab so it can do the rsync as follows, the crontab is like M$ Windoze schedular

Type the following

$ crontab -e

add the folowing entry to the crontab

05 * * * * /the/path/to/your/script > /dev/null 2>&1

Close your editor and the crontab will be saved
the script should run every 5 minutes

Cheers
 
Old 09-29-2006, 11:34 PM   #4
venki
Member
 
Registered: Sep 2006
Location: India
Distribution: suse10.2
Posts: 128

Original Poster
Rep: Reputation: 15
thank u very much,

but i want the tar file to be in the backup directory and also whn i am running backup.sh only it is storing in the backup other wise there is no backup ..

then what is the need of crontab??

please help me
 
Old 09-30-2006, 01:39 PM   #5
shawnbishop
Member
 
Registered: Dec 2005
Location: South Africa
Distribution: CentOS,Ubuntu,Fedora
Posts: 249

Rep: Reputation: 30
Good Day

I am not sure I understand what you are saying, the crontab is the same as the Windows Task Scheduler, that is it enables you to run certain tasks repeatedly at a certain time.

to understand this command type the following

$ man crontab

From what you are saying you now what the backup files tarred/zipped etc...?? Go and have a look at the following links

www.linux-backup.net or go to the following PDF file which will explain

http://tldp.org/HOWTO/Linux-Complete...ecovery-HOWTO/

This will give you a complete guide of doing a linux backup.

Cheers
 
Old 10-03-2006, 05:59 AM   #6
venki
Member
 
Registered: Sep 2006
Location: India
Distribution: suse10.2
Posts: 128

Original Poster
Rep: Reputation: 15
what is the problem with this

thks very much for giving fast replies

i am now able to work with cronjobs but

tar -czf /cytrion-station8/workspace/Archive/`date +%d-%m-%Y `/data.tar.gz /cytrion-station8/workspace/Active/`date +%d-%m-%Y `

by the above i am creating tar file called data.tar.gz

when i am extracting this tar file i have /cytrion-station8/workspace/Active/03-10-2006/....

i dont want all these things i want just from 03-10-2006....

but all these /cytrion.......

unnecessary stuff is coming..

please help
 
Old 10-03-2006, 09:06 AM   #7
konsolebox
Senior Member
 
Registered: Oct 2005
Distribution: Gentoo, Slackware, LFS
Posts: 2,248
Blog Entries: 8

Rep: Reputation: 235Reputation: 235Reputation: 235
do you mean
Code:
mkdir -p /cytrion-station8/workspace/Active/`date +%d-%m-%Y `
pushd /cytrion-station8/workspace/Active/ > /dev/null
tar -czf `date +%d-%m-%Y `/data.tar.gz `date +%d-%m-%Y `
popd > /dev/null
 
Old 10-03-2006, 11:54 PM   #8
venki
Member
 
Registered: Sep 2006
Location: India
Distribution: suse10.2
Posts: 128

Original Poster
Rep: Reputation: 15
code is :

mkdir /cytrion-station8/workspace/Archive/`date +%d-%m-%Y `



tar cvjf /cytrion-station8/workspace/Archive/`date +%d-%m-%Y `/data.tar.bz2



when i am extracting data.tar.bz2 ....then i have to see from the date folder but i am seeing from cytrion-station8 folder


please help me
 
  


Reply



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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
small syntax problem with C code (implemented in Code Composer Studio) illiniguy3043 Programming 6 01-07-2008 02:14 AM
LXer: Backup MySQL databases, web server files to a FTP server automatically LXer Syndicated Linux News 0 08-11-2006 09:54 PM
Automatically fix and indent C code? mic Programming 6 08-25-2005 09:07 PM
User Preferences: Use HTML code instead of vB code? (vB code is overrated) stefanlasiewski LQ Suggestions & Feedback 5 07-26-2005 01:37 AM
startup backup agent automatically when reboot ashley75 Linux - General 1 07-18-2005 03:39 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration