UnitedForums - UK Web Hosting Forum UnitedHosting Community Hosting Forums
Network and Server StatusCustomer SupportUK Web Hosting
UnitedHostingUnitedHosting Sitemap UK Hosting ForumUK Web HostingWeb Hosting ForumsUK Reseller HostingWeb Host CommunityUK Managed Dedicated ServersHosting Help and SupportUK Domain Name Registration

Go Back   UnitedForums.co.uk > UnitedHosting Community > Website Development & Scripting

Reply
 
Thread Tools Rate Thread Display Modes
Old 6th January 2008, 09:06 PM   #1 (permalink)
canuckster
Lumberjack and I'm okay
 
Join Date: Dec 2004
Location: Canada
Posts: 243
Zipping files via PHP 4

I want to set up a cron job that will back up (in human readable form) the data from a particular database table once a month by writing a text file, zipping it, and then attaching the zip file to an email. The part I need help with is the zipping.

From what I understand, I need functions like zip_open() to do this, but I just tried it and it's undefined, suggesting the required library is not installed (or enabled). Is this something I should open up a ticket for? Or is there another way I should be doing this?
canuckster is offline   Reply With Quote
Old 7th January 2008, 12:48 AM   #2 (permalink)
Charles
Registered User
 
Join Date: Sep 2007
Location: 17°59′N 76°48′W
Posts: 150
Quote:
Originally Posted by canuckster View Post
I want to set up a cron job that will back up (in human readable form) the data from a particular database table once a month by writing a text file, zipping it, and then attaching the zip file to an email. The part I need help with is the zipping.

From what I understand, I need functions like zip_open() to do this, but I just tried it and it's undefined, suggesting the required library is not installed (or enabled). Is this something I should open up a ticket for? Or is there another way I should be doing this?
You might want to take a look at this:
PHP: Zip - Manual

If you need something loaded then you would need to open up a support ticket.
Charles is offline   Reply With Quote
Old 7th January 2008, 01:37 AM   #3 (permalink)
percepts
Senile Member
 
percepts's Avatar
 
Join Date: Mar 2005
Posts: 1,009
I know you asked about zip but I would suggest you look at using gzip which you can run very simply from php and fast.

example

gzip a a file called var/www/html/sqlbackup/monday

exec("gzip var/www/html/sqlbackup/monday");

would create var/www/html/sqlbackup/monday.gz

.gz files open and decompress in winzip and stuffit on windows.

piece of cake.
__________________
An old dog learning new tricks
percepts is offline   Reply With Quote
Old 7th January 2008, 01:54 AM   #4 (permalink)
canuckster
Lumberjack and I'm okay
 
Join Date: Dec 2004
Location: Canada
Posts: 243
I'll give that a try. I never knew php could execute scripts that way.
canuckster is offline   Reply With Quote
Old 7th January 2008, 02:22 AM   #5 (permalink)
canuckster
Lumberjack and I'm okay
 
Join Date: Dec 2004
Location: Canada
Posts: 243
It didn't work. I run the script and nothing happens -- no error, no resulting .gz file. At first I thought it might be related to permissions, but they're set to
-rwxr-xr--

Do you know what I'm doing wrong?
canuckster is offline   Reply With Quote
Old 7th January 2008, 03:44 AM   #6 (permalink)
Charles
Registered User
 
Join Date: Sep 2007
Location: 17°59′N 76°48′W
Posts: 150
I think you have to have a / in front of the var/www/ part
/var/www/html/........
Charles is offline   Reply With Quote
Old 7th January 2008, 04:08 AM   #7 (permalink)
percepts
Senile Member
 
percepts's Avatar
 
Join Date: Mar 2005
Posts: 1,009
Oops, yes there should be a leading slash
__________________
An old dog learning new tricks
percepts is offline   Reply With Quote
Old 7th January 2008, 05:14 PM   #8 (permalink)
canuckster
Lumberjack and I'm okay
 
Join Date: Dec 2004
Location: Canada
Posts: 243
Actually, I noticed that and wondered the same thing, so I tried it both ways -- with and without the leading slash -- and got the same (non) result ...
canuckster is offline   Reply With Quote
Old 7th January 2008, 05:20 PM   #9 (permalink)
desquinn
Senior Member
 
Join Date: Dec 2005
Location: Paisley
Posts: 332
Should you maybe be specifying the full path to Gzip as well i.e. /bin/gzip
desquinn is offline   Reply With Quote
Old 7th January 2008, 06:43 PM   #10 (permalink)
percepts
Senile Member
 
percepts's Avatar
 
Join Date: Mar 2005
Posts: 1,009
full path to gzip not required on UH servers but possibly required on windows if you are testing locally.

the directory in which the file to be gzipped is chmod 755. I have a cron which does this and works fine and I just ran a test and it works fine.

It won't work locally on windows unless you have installed gzip. I believe gzip comes with nix OS systems but is certainly on UH servers as standard.

check your httpd error log to see if there are any clues as to failure.
__________________
An old dog learning new tricks
percepts is offline   Reply With Quote
Old 7th January 2008, 07:07 PM   #11 (permalink)
canuckster
Lumberjack and I'm okay
 
Join Date: Dec 2004
Location: Canada
Posts: 243
It works now.

It was a permissions problem; I'd set Owner and Group to execute, but not Other (I think that was 754 instead of 755).

Thanks for all the help.
canuckster is offline   Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 08:56 PM.

UK Web Hosting  |  UK Reseller Hosting  |  UK Dedicated Servers UnitedHosting  |  UnitedSupport  |  UnitedForums  |  SEO by vBSEO 3.0.0
Copyright © 1998-2008 United Communications Limited. All Rights Reserved. Registered in England and Wales 3651923 - VAT Reg No. 737662309