LinuxQuestions.org
Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-08-2009, 07:27 AM   #1
prudens
Member
 
Registered: Jul 2009
Posts: 52

Rep: Reputation: 15
Question Cron job to backup


Hi,

Expert please help me. I use Ubuntu Server and I only wish to create a cron job everyday at 3AM to backup my directory /home/ and tar it, and add password "LINUXRULEZ" to it, then FTP it to ftp.linuxrulez.com using username LINUX password RULEZ

Can you help me please?
 
Old 08-08-2009, 07:39 AM   #2
shahz
Member
 
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL, Ubuntu, Fedora
Posts: 368

Rep: Reputation: 29
try it your self when you are in between and have problems then ask every one to get you one step above.
 
Old 08-08-2009, 07:40 AM   #3
prudens
Member
 
Registered: Jul 2009
Posts: 52

Original Poster
Rep: Reputation: 15
heh heh, the problem is, i'm only 10 years old and don't really understand still after I read some articles on it. Can you help a 10 year old ples?
 
Old 08-08-2009, 07:45 AM   #4
shahz
Member
 
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL, Ubuntu, Fedora
Posts: 368

Rep: Reputation: 29
well then get elder and then try Linux, but while learning don't use feeder.
 
Old 08-08-2009, 07:49 AM   #5
prudens
Member
 
Registered: Jul 2009
Posts: 52

Original Poster
Rep: Reputation: 15
why are you so mean -.- pakistan
 
Old 08-08-2009, 07:49 AM   #6
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Exclamation

Quote:
Originally Posted by shahz View Post
well then get elder and then try Linux, but while learning don't use feeder.
Shahz,

This is not quite the attitude we would like the OP to think we at LQ have, regarding young people using Linux.

If you cannot offer constructive help, kindly at least allow others to do so.

Sasha
 
Old 08-08-2009, 07:52 AM   #7
shahz
Member
 
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL, Ubuntu, Fedora
Posts: 368

Rep: Reputation: 29
well dear moderator

I din't stop any one to help some one, I am also learning. but do you think that he can be answerd for every thing which he din't try yet.
 
Old 08-08-2009, 08:11 AM   #8
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Arch/XFCE
Posts: 17,802

Rep: Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738Reputation: 738
Quote:
Originally Posted by shahz View Post
well dear moderator

I din't stop any one to help some one, I am also learning. but do you think that he can be answerd for every thing which he din't try yet.
With obvious homework, we sometimes tell people to show their work first. I don't think that applies in this case. Let's just try to help.....
 
Old 08-08-2009, 08:15 AM   #9
shahz
Member
 
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL, Ubuntu, Fedora
Posts: 368

Rep: Reputation: 29
Quote:
Originally Posted by pixellany View Post
With obvious homework, we sometimes tell people to show their work first. I don't think that applies in this case. Let's just try to help.....
ok brother
 
Old 08-08-2009, 08:18 AM   #10
prudens
Member
 
Registered: Jul 2009
Posts: 52

Original Poster
Rep: Reputation: 15
pls help me, i am trying to back up my homework which is stored in /home/
 
Old 08-08-2009, 08:28 AM   #11
GrapefruiTgirl
LQ Guru
 
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Hi prudens,

Ok, I will suggest a first step that you should take: First, read the manual pages (the help pages) for the `cron` tool, and for the `tar` command.
You can read this documentation by using a command as follows, from your console:

Code:
shell$ man crond

shell$ man tar
This should give you a good idea how to use the cron program, and how to configure a crontab file for your 0300 job.
Also, the `tar` man page should give good detail of using tar and gzip to archive your /home folder.

After doing a bit of reading there, show us what you have come up with as far as the crontab settings for the job, and what command you think you need to archive the /home folder.
We'll see what you've got, and advise from there.

Personally, I'm not too experienced with the ftp aspect of your request, so someone will help or offer ideas for that part later.

Sasha
 
Old 08-08-2009, 09:24 AM   #12
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,576
Blog Entries: 31

Rep: Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195Reputation: 1195
Hello prudens (wise one)

Have you decided what language to use? Bash shellscript is suitable and easy to debug.

The easiest way to approach software development like this is to take it in bite-sized chunks and do each step manually, for familiarisation, before linking them all together in a script.

You could start by doing the tar and FTP parts at the command line. Man pages are good references but not the easiest introduction. I've been using *n*x systems a while and I still go looking for examples (HOWTOs and FAQs) on the Internet if the man page does not make sense straight away.

Here's a page exampling tar.

There are lots of FTP HOWTOs and FAQs so Google for FTP HOWTO or FAQ and pick the one you get on best with.

The environment your script will eventually run in, set up by cron, is different from the login environment and this often causes breakage. In particular, the $PATH variable is different so safest to use full paths for your commands, example /usr/bin/ftp rather than ftp.

You may also like to include a date in your tar archive (output) file name so you can store several on ftp.linuxrulez.com. That way, if you find you want a file that was deleted a while ago you can get an old tar archive and restore it.

When you come to scripting the FTP put (upload) you will probably want something like
Code:
ftp $host_name <put_script>> put_out 2>&1
This feeds whatever is in file put_script to the ftp program, the same as when you are entering the commands at the terminal by hand. All the output from the ftp command is sent to file put_out which will be a valuable troubleshooting aid.

When (if?) you get stuck or want feedback on whether you are doing things the best way, post what you've done here. It's easier to read your stuff if you put it in CODE tags, that's the word CODE in brackets [] to begin and /CODE in brackets to end.

Looking ahead to when you've got it working I strongly recommend that you also get your backup file from ftp.linuxrulez.com and test that it can be used to restore files; many people have only found out that their backups don't work when they try to restore from them!

Finally, your backup script may fail; if it writes a log and you can discipline yourself to check it regularly then you will avoid the danger of thinking the backup is working until you need to restore something and find the script wasn't working for the last few months!

Best

Charles
 
Old 08-08-2009, 09:28 AM   #13
prudens
Member
 
Registered: Jul 2009
Posts: 52

Original Poster
Rep: Reputation: 15
ooo thank you guys very much for going in great depth! I'll spend the next few days reading and learning from you guys hahahaa.
 
Old 08-09-2009, 08:04 PM   #14
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.9, Centos 7.3
Posts: 17,356

Rep: Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367Reputation: 2367
Here's a good example of how to use cron.
http://www.adminschoice.com/docs/cro...Crontab%20file
I hope that your target is not on the net as you've given the user/passwd combo. You should change that.
 
Old 08-10-2009, 06:51 AM   #15
jeromeNP7
Member
 
Registered: Jun 2009
Posts: 101

Rep: Reputation: 19
Very good english for a 10 year old boy from Pakistan. And very busy with his homework, if he needs to have it backed up everyday at 3AM. Is this the usual amount of homework for children at that region, or is the poster playing games with this forum?

Linux

Last edited by jeromeNP7; 09-04-2009 at 08:55 PM.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Backup script won't run in cron job. Why? Micro420 Linux - General 19 10-31-2007 08:26 PM
SSH remote backup fail on cron job - keychain eyt Linux - General 4 07-17-2007 10:17 PM
How to improve my mysql backup cron job stardotstar Programming 8 05-25-2006 06:11 AM
cron backup job not running dsschanze Linux - General 9 07-29-2005 08:47 PM
cron job - backup medamnit Linux - Newbie 4 05-24-2002 03:37 AM


All times are GMT -5. The time now is 09:51 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration