FutureQuest, Inc. FutureQuest, Inc. FutureQuest, Inc.

FutureQuest, Inc.
Go Back   FutureQuest Community > General Site Owner Support (All may read/respond) > General FutureQuest Hosting Support
User Name
Password  Lost PW

Reply
 
Thread Tools Search this Thread Display Modes
Old 11-13-2003, 11:57 AM   Postid: 100229
ffurtado
Site Owner

Forum Notability:
10 pts: User-friendly
[Post Feedback]
 
Join Date: Sep 2002
Posts: 76
Crontab Backup Script

I'm looking for a solution to backup a few log files using a Crontab. Does anyone have any experience with this script?

World Wide Backup - Our latest free script that will allow you to backup your website and even gives you the option to FTP that backup to another server. Requires that your server has Tar (most UNIX/Linux based systems do). For the FTP option, you also will need the Net::FTP module installed on your server (again, most do). The script also can email you when the backup is finished (or if there was an error). This script is not a .cgi script that you can execute from a browser. You will need either telnet (shell) access to your server, OR crontab access to your server.

http://www.worldwidecreations.com/freescripts.htm

Thanks,
Fred
ffurtado is offline   Reply With Quote
Old 11-13-2003, 12:48 PM   Postid: 100231
 Kevin
Systems Administrator
 
Kevin's Avatar
 
Join Date: Aug 2001
Location: Orlando, FL
Posts: 2,481
Fred,
I do not have any experience with that particular backup script however we do have tar and Net::FTP installed and we do provide both shell and cron access so it should work.

If you need help with cron there is a tutorial here: http://www.aota.net/Script_Installat.../cronhelp.php4

--
Kevin
Kevin is offline   Reply With Quote
Old 11-13-2003, 02:16 PM   Postid: 100241
ffurtado
Site Owner

Forum Notability:
10 pts: User-friendly
[Post Feedback]
 
Join Date: Sep 2002
Posts: 76
Thank you for the information.

The problem is that I need a perl script to *call* in the Crontab file to backup the few files in question. I don't have a .pl script and I don't know how to write such a script. I have not been able to find a backup script anywhere that I could modify slightly for my needs.

I have been using the Windows XP Scheduler to run my CuteFTP program at 9:50 AM. In CuteFTP, I scheduled a transfer to download three files to my computer at 10:00AM.

This works Ok, but I have a dial-up connection to the Internet, so I have to be sure my computer is on and connected to the Internet at the appropriate time.

I really need a Crontab job to automatically backup the 3 files and send me an email telling me it was done (without the use of my computer).

Fred
ffurtado is offline   Reply With Quote
Old 11-14-2003, 07:48 PM   Postid: 100396
ffurtado
Site Owner

Forum Notability:
10 pts: User-friendly
[Post Feedback]
 
Join Date: Sep 2002
Posts: 76
I have spent hours looking for a perl script I can modify to accomplish a very simple backup using Crontab. I would appreciate help finding such a script.

Crontab
At 11:50PM every day
backup.pl

backup.pl script should do this:

1. Copy the 4 ".log" files from my /cgi-bin/data folder to my cgi-bin/data/backup folder

2. Email me a message saying it was done. I can use a sendmail routine I have for the email function.

Or maybe a cron like this might work:
50 11 * * * cd /big/dom/xdomain/cgi-bin/data;tar -cvf - * | tar -C /big/dom/xdomain/cgi-bin/data/backup/ -xv

I don't have much experience with Perl, Tar, or Cron jobs.

Thanks,
Fred
ffurtado is offline   Reply With Quote
Old 11-15-2003, 10:55 AM   Postid: 100457
 Kevin
Systems Administrator
 
Kevin's Avatar
 
Join Date: Aug 2001
Location: Orlando, FL
Posts: 2,481
Quote:
Originally posted by ffurtado:

Crontab
At 11:50PM every day
backup.pl

backup.pl script should do this:
/big/dom/xdomain/cgi-bin/data/backup/
1. Copy the 4 ".log" files from my /cgi-bin/data folder to my cgi-bin/data/backup folder

2. Email me a message saying it was done. I can use a sendmail routine I have for the email function.

Or maybe a cron like this might work:
50 11 * * * cd /big/dom/xdomain/cgi-bin/data;tar -cvf - * | tar -C /big/dom/xdomain/cgi-bin/data/backup/ -xv
Fred,
if all you want is to copy some files from one directory to another the cron job would be pretty simple:

50 11 * * * cp -fv /big/dom/xdomain/cgi-bin/data/*.log /big/dom/xdomain/cgi-bin/data/backup/

That would copy all of the logfiles overwriting the previous backup and cron would send the output to the email address listed on the MAILTO= line of the crontab.

--
Kevin
Kevin is offline   Reply With Quote
Old 11-15-2003, 12:19 PM   Postid: 100463
ffurtado
Site Owner

Forum Notability:
10 pts: User-friendly
[Post Feedback]
 
Join Date: Sep 2002
Posts: 76
Kevin, thank you for your reply.

Before I risk any possible harm to my files, I'd like to double-check this procedure with you.

*** My Backup Cron Job ***

Copy all log files in specified directory to a new backup directory
Overwrite previous backup files if present in backup directory
Send the output to the email address listed.
Daily at 11:50PM

Note: replace xdomain with user account

1. Create new directory /big/dom/xdomain/cgi-bin/cronjobs
2. CHMOD 755
3. Create text file "logcron.txt"

MAILTO=webmaster@domain.com
50 11 * * * cp -fv /big/dom/xdomain/cgi-bin/data/*.log /big/dom/xdomain/cgi-bin/data/backup/
[ENTER for last line]

4. Copy "logcron.txt" to /big/dom/xdomain/cgi-bin/cronjobs directory (upload in ASCII)

5. Telnet into account and issue the following command:

crontab /big/dom/xdomain/cgibin/cronjobs/logcron.txt

I do not know what to expect from this:
"Send the output to the email address listed"
What is the output I receive in the email?

Thank you,
Fred
ffurtado is offline   Reply With Quote
Old 11-15-2003, 12:28 PM   Postid: 100464
 Kevin
Systems Administrator
 
Kevin's Avatar
 
Join Date: Aug 2001
Location: Orlando, FL
Posts: 2,481
Fred,
Your script is correct as is your method for getting it into the crontab. However, you should be aware that when you run 'crontab [file]' it overwrites what is in the crontab instead of adding to it therefore if you ever have multiple cron jobs they should all be in one text file not multiple text files in a cronjobs directory. IOW, it looks like you were planning to setup for multiple cron jobs in separate text files and that will not work. Every time you want to change or add to the crontab you must use a master text file with all of the jobs in it. If you lose that file you can regenerate it with the following command:
$ crontab -l > textfile

Quote:
I do not know what to expect from this:
"Send the output to the email address listed"
What is the output I receive in the email?


The -v parameter on the cp command will cause it to be verbose and it will print something like:
'sourcefile' -> 'destfile'
for each file that it copies. Cron automatically sends that output (along with any errors) in an email unless told not to.

--
Kevin
Kevin is offline   Reply With Quote
Old 11-15-2003, 01:08 PM   Postid: 100468
ffurtado
Site Owner

Forum Notability:
10 pts: User-friendly
[Post Feedback]
 
Join Date: Sep 2002
Posts: 76
Hello Kevin,

Whew!
Thank you for that last bit of information.

Yes, I have log files for 3 different versions of the same database program.

The .log files are located in separate directories and I want to use the crontab job to back them all up to the one backup directory. Do I repeat the commands like this in the crontab file?

MAILTO=webmaster@domain.com
50 11 * * * cp -fv /big/dom/xdomain/cgi-bin/data/*.log /big/dom/xdomain/cgi-bin/data/backup/
50 11 * * * cp -fv /big/dom/xdomain/cgi-bin/data2/*.log /big/dom/xdomain/cgi-bin/data2/backup/
50 11 * * * cp -fv /big/dom/xdomain/cgi-bin/data3/*.log /big/dom/xdomain/cgi-bin/data3/backup/
[ENTER for last line]

3 separate cp's
/data directory
/data2 directory
/data3 directory

Fred
ffurtado is offline   Reply With Quote
Old 11-15-2003, 01:14 PM   Postid: 100469
 Kevin
Systems Administrator
 
Kevin's Avatar
 
Join Date: Aug 2001
Location: Orlando, FL
Posts: 2,481
Fred,
That will backup the log files in all 3 directories but it will back them up to 3 different directories since you specified 3 different targets. If you want them all backed up to the same directory then make all the targets the same. Also, if you want to backup all the logs in all the data directories to the same backup directory you could do it in one job like this:

50 11 * * * cp -fv /big/dom/xdomain/cgi-bin/data*/*.log /big/dom/xdomain/[backup dir]/

--
Kevin
Kevin is offline   Reply With Quote
Old 11-15-2003, 01:32 PM   Postid: 100472
 Kevin
Systems Administrator
 
Kevin's Avatar
 
Join Date: Aug 2001
Location: Orlando, FL
Posts: 2,481
Fred,
One more thing I just noticed. You said to run the job at 11:50 pm however cron operates on a 24 hour clock so you need to use 23 instead of 11 in your cron jobs.

--
Kevin
Kevin is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 visitors)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -4. The time now is 03:56 AM.


Running on vBulletin®
Copyright © 2000 - 2013, Jelsoft Enterprises Ltd.
Hosted & Administrated by FutureQuest, Inc.
Images & content copyright © 1998-2013 FutureQuest, Inc.
FutureQuest, Inc.