Previous Thread
Next Thread
Print Thread
Rate Thread
#240847 03/16/2003 1:47 PM
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Anyone ever here of a script that allows you to zip and download a whole web directory... for backup purposes. Or could that easily be created in php?

A point and click solution to backup uploaded files would be very handy. Especially here to backup the hacks. FTP is a pain.... as is shell access.

Last edited by JoshPet; 03/16/2003 1:48 PM.
Sponsored Links
Daine #240848 03/16/2003 2:19 PM
Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
Found one here: http://www.optimall-soft.com/products/web_archiver/
But it costs money.

Couldn't find anything else though. But it shouldn't be too hard to write a script to zip a folder.

c0bra #240849 03/16/2003 2:28 PM
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Thanks I will check that out.

$29 isnt' too bad for piece of mind.

Daine #240850 03/16/2003 2:54 PM
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Unless you'd care to give me some pointers/code tidbits to zipping a directory.

Daine #240851 03/16/2003 3:05 PM
Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
I did find a function library to handle zip files, but didn't realize that they also had a finished script to use the functions. You can find the script here:
http://www.phpconcept.net/phpzip/index.en.php

There's not much info in english, but it seems to be what you are asking for.

Sponsored Links
c0bra #240852 03/16/2003 4:14 PM
Joined: Apr 2002
Posts: 1,768
Addict
Addict
Offline
Joined: Apr 2002
Posts: 1,768
On a *nix server, it's better to use tar and gzip if possible, since tar preserves the file attributes.

joeuser #240853 03/16/2003 5:05 PM
Joined: May 1999
Posts: 1,715
Addict
Addict
Joined: May 1999
Posts: 1,715
Yeah, and I think that second script is supposed to use that. Although it didn't seem to work that well on php4 with register globals off or with mozilla. Couldn't find out how to actually move files into the archive it created either.

If I'd write something, I think I'd just write a quick directory selector script and pass the path to a small script that uses system() to call on tar. But using system() is always risky, so some checks should be done.

Daine #240854 03/16/2003 5:07 PM
Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
You may want to have a look at
http://www.phpclasses.org

Especially for the class names "Zip/Tar/GZip Archives"

Description:
Allows the creation of zip, tar, and gzip archives, and extraction of tar and gzip.
Supports relative paths/no paths, comments, and recursing through subdirectories.
Can write file to disk, allow user to download directly, or can return file contents in a string.
It doesn't require any external programs to run. PHP must be compiled with '--with-zlib' because gzcompress, gzdeflate, and gzinflate are used for gzip and zip files, but creation of tar files will work regardless of whether or not this option is set.

You'll have to register to download it, but it's free.
phpclasses.org is a great resource for all kind of php classes.

-Fusion- #240855 03/16/2003 10:49 PM
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Thank you.

I couldnt' figure out how to buy the first one. And I couldn't make the second one work. I'll give this a go.

Daine #240856 03/18/2003 12:48 AM
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Well this got me closer.

I downloaded the attached classes and functions... but I'm still having trouble making it work.
Attachments
73451-archive.txt (0 Bytes, 33 downloads)

Sponsored Links
Daine #240857 03/18/2003 12:50 AM
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369
Then I tried a script like this. And it does produce a file for download. But the contents of the file aren't right. I'm trying to tar and zip a directory. Like to tar/zip and download a threads attachment directory.

Code
<br /><?<br /><br />require ("archive.php");<br /><br />$dirlist = "/mnt/drive2/joshuapettit/htdocs/test";<br />$filename = "test.tar";<br /><br /><br />$example = new gzfile("/mnt/drive2/joshuapettit/htdocs");<br />$example->adddirectories($dirlist);<br /><br />$example->filedownload($filename);<br /><br />echo "done";<br />	<br /><br />?>

Daine #240858 03/18/2003 4:01 AM
Joined: Dec 2000
Posts: 1,471
Addict
Addict
Offline
Joined: Dec 2000
Posts: 1,471
I think $dirlist should contain a relative path from your working directory you specified as "/mnt/drive2/joshuapettit/htdocs"

-Fusion- #240859 03/19/2003 11:57 AM
Joined: Feb 2002
Posts: 1,759
Addict
Addict
Offline
Joined: Feb 2002
Posts: 1,759
I like tar/gzip:

tar -zcvpf /path/to/save/backup.tar.gz . --directory /directory/to/backup

z = compress
c = create new archive
v = verbose (just to see what its doing)
p = preserve permissions
f = the path following this is where to save the file

I just backed up my whole 1.5 GB site and moved it to a new server. Ran that command from my home directory, it packaged it all up perfectly. Transfered it to my new server, put the tarball in the home directory and ran this:

tar -zxvpf backup.tar.gz --directory /home/myfolder/

It was great, it extracted all of my directories and preserved all of the file permissions in a matter of minutes

If you want and don't use a control panel like cPanel and such, you could create a cron job to do this every night if you wanted.. to run the backup of a specified folder and store them on the server

palmen #240860 03/19/2003 11:59 PM
Joined: Oct 2000
Posts: 2,223
Veteran
Veteran
Offline
Joined: Oct 2000
Posts: 2,223
Josh, is that thing making a gz file and you're naming it with a .tar extension?


Picture perfect penmanship here.
zerind #240861 03/20/2003 12:21 AM
Joined: Nov 2001
Posts: 10,369
I type Like navaho
I type Like navaho
Joined: Nov 2001
Posts: 10,369


Ok - so that would be one issue. <doah>
<slaps head>



Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Bill B
Bill B
Issaquah, WA
Posts: 87
Joined: December 2001
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20240506)