LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Cron job to backup (https://www.linuxquestions.org/questions/linux-newbie-8/cron-job-to-backup-746021/)

prudens 08-08-2009 07:27 AM

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?

shahz 08-08-2009 07:39 AM

try it your self when you are in between and have problems then ask every one to get you one step above.

prudens 08-08-2009 07:40 AM

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?

shahz 08-08-2009 07:45 AM

well then get elder and then try Linux, but while learning don't use feeder.

prudens 08-08-2009 07:49 AM

why are you so mean -.- pakistan

GrapefruiTgirl 08-08-2009 07:49 AM

Quote:

Originally Posted by shahz (Post 3635711)
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

shahz 08-08-2009 07:52 AM

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.

pixellany 08-08-2009 08:11 AM

Quote:

Originally Posted by shahz (Post 3635718)
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.....

shahz 08-08-2009 08:15 AM

Quote:

Originally Posted by pixellany (Post 3635733)
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 :)

prudens 08-08-2009 08:18 AM

pls help me, i am trying to back up my homework which is stored in /home/

GrapefruiTgirl 08-08-2009 08:28 AM

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

catkin 08-08-2009 09:24 AM

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

prudens 08-08-2009 09:28 AM

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.

chrism01 08-09-2009 08:04 PM

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.

jeromeNP7 08-10-2009 06:51 AM

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


All times are GMT -5. The time now is 02:43 PM.