Operating System - Linux
1833050 Members
2210 Online
110049 Solutions
New Discussion

how to save daily from cron job the whole Web servers data ?

 
SOLVED
Go to solution
'chris'
Super Advisor

how to save daily from cron job the whole Web servers data ?

hi

how to save daily from cron job the whole Web servers date from /srv/www
and send it via ftp to other linux server ?
I would be very glad, if someone could
post the script.

kind regards
chris
7 REPLIES 7
Steven E. Protter
Exalted Contributor

Re: how to save daily from cron job the whole Web servers data ?

I will give you an outline and post the script.

You'll still have to work, because I'm using openssh/Secure Shell(on the HP-UX) side. I won't use ftp scripts because of the clear text user authentication.

First you create a tar file.

cd /svr/www

tar cvf /tmp/webbackup.tar *

This will back up everything under the directory you cd'd to.

Alternate command line:

tar cvf /tmp/webback.tar /svr/www/*

Same basic idea.

You might want the p parameter for tar to preserve the full path of the files.

Now you have a backup.

For maximum transmission efficiency, gzip the file.

gzip /tmp/webback.tar

The filename is now: /tmp/webback.tar.gz

Assuming you have openssh/Secure Shell and exchange public keys, you can transmit the file to another server.

scp -p /tmp/webback.tar.gz root@linux://tmp

That will go automatically.

Now the cron job on the target server:

gunzip /tmp/webback.tar.gz

That's what you asked for.

I can't provide a script because my firewall won't let me access it(a good thing). When I get home in two hours, I'll post up the script, which has full path names and actually runs in cron.

good luck,

regards,

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Balaji N
Honored Contributor

Re: how to save daily from cron job the whole Web servers data ?

chris,

SEP has given the outline. it details what needs to be done. so i would suggest you to work a script on your own and post back if ur having problems. this helps u understand the scripts and also will also help u when u have problems with this script.

dont expect to be spoon fed.
-balaji
Its Always Important To Know, What People Think Of You. Then, Of Course, You Surprise Them By Giving More.
Steven E. Protter
Exalted Contributor
Solution

Re: how to save daily from cron job the whole Web servers data ?

A wee bit of spooon feeding.

Attaching copyprod script.

This is run on the target server by cron. It copies over the backup file from the production server and puts the web data some sendmail config backup and DNS into the backup server.

Note: All three of my servers are Master servers, capable of running the Enterprise. This is to protect from hardware failures.

See attachment:

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Steven E. Protter
Exalted Contributor

Re: how to save daily from cron job the whole Web servers data ?

The script that creates the backup.

As noted, my setup has the second server pulling the backup, not the production server pushing it. Its cleaner that way, less chance of errors. If the network connection isn't there, the copyprod script terminates without any harm being done.

See attachment


Production environment is Red Hat 7.3 apache 1.3.x BIND 9.2.x sendmail 8.11, all fully patches.

SEP
makebackup
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
'chris'
Super Advisor

Re: how to save daily from cron job the whole Web servers data ?

hi steven

thanks very, very much.
but how is the entry for the cron job
to run this script ?
and I did not see the entry for
the ftp command

best regards
chris

Steven E. Protter
Exalted Contributor

Re: how to save daily from cron job the whole Web servers data ?

cron entries for the two scripts.

apologies for the delay.

makebackup on the production server:

5 0 * * * /usr/contrib/bin/makebackup 2>&1

This runs it once a day at 5 minutes past midnight.

I now run it hourly at five minutes past the hour. To do that change the zero to *

on the backup server, here is the cron entry for the copyrpod script.


5 1 * * * /usr/contrib/bin/copyprod 2>&1


That runs it at 1:05 a.m. which gives the midnight backup an hour to finish.

You'll need to have public keys exchanged on openssh to make this work. Attaching a document.

If I was a jerk in the other thread, I'm sorry. The date has really gotten to me. The more I try to ignore it, the nastier and more obnoxious I become. That just covers for the sadness.

Hope this helps.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
'chris'
Super Advisor

Re: how to save daily from cron job the whole Web servers data ?

thanks !