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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
|
08-08-2009, 07:27 AM
|
#1
|
Member
Registered: Jul 2009
Posts: 52
Rep:
|
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?
|
|
|
08-08-2009, 07:39 AM
|
#2
|
Member
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL, Ubuntu, Fedora
Posts: 368
Rep:
|
try it your self when you are in between and have problems then ask every one to get you one step above.
|
|
|
08-08-2009, 07:40 AM
|
#3
|
Member
Registered: Jul 2009
Posts: 52
Original Poster
Rep:
|
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?
|
|
|
08-08-2009, 07:45 AM
|
#4
|
Member
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL, Ubuntu, Fedora
Posts: 368
Rep:
|
well then get elder and then try Linux, but while learning don't use feeder.
|
|
|
08-08-2009, 07:49 AM
|
#5
|
Member
Registered: Jul 2009
Posts: 52
Original Poster
Rep:
|
why are you so mean -.- pakistan
|
|
|
08-08-2009, 07:49 AM
|
#6
|
LQ Guru
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594
|
Quote:
Originally Posted by shahz
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
|
|
|
08-08-2009, 07:52 AM
|
#7
|
Member
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL, Ubuntu, Fedora
Posts: 368
Rep:
|
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.
|
|
|
08-08-2009, 08:11 AM
|
#8
|
LQ Veteran
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809
|
Quote:
Originally Posted by shahz
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.....
|
|
|
08-08-2009, 08:15 AM
|
#9
|
Member
Registered: Sep 2006
Location: Quetta, Pakistan
Distribution: RHEL, Ubuntu, Fedora
Posts: 368
Rep:
|
Quote:
Originally Posted by pixellany
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 
|
|
|
08-08-2009, 08:18 AM
|
#10
|
Member
Registered: Jul 2009
Posts: 52
Original Poster
Rep:
|
pls help me, i am trying to back up my homework which is stored in /home/
|
|
|
08-08-2009, 08:28 AM
|
#11
|
LQ Guru
Registered: Dec 2006
Location: underground
Distribution: Slackware64
Posts: 7,594
|
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
|
|
|
08-08-2009, 09:24 AM
|
#12
|
LQ 5k Club
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
|
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
|
|
|
08-08-2009, 09:28 AM
|
#13
|
Member
Registered: Jul 2009
Posts: 52
Original Poster
Rep:
|
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.
|
|
|
08-09-2009, 08:04 PM
|
#14
|
LQ Guru
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.x
Posts: 18,443
|
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.
|
|
|
08-10-2009, 06:51 AM
|
#15
|
Member
Registered: Jun 2009
Posts: 101
Rep:
|
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.
|
|
|
All times are GMT -5. The time now is 01:14 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|