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.
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.
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.
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.
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
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.