Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,576 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,887 people online right now. Registration is fast and FREE... Join Now!




downloading that which is not ussually downloadable

 
Reply to this topicStart new topic

downloading that which is not ussually downloadable, <_<

Andora
4 Oct, 2008 - 01:10 PM
Post #1

D.I.C Head
**

Joined: 18 Aug, 2008
Posts: 105


My Contributions
I want to create a download link on my site that will download the entire site site for backup purposes: php source codes, txt based database, everything. However I just can't seem to get started, is this possible? I heard something about a cache but I have no idea what that is or how it would help.

thanks,
Andora
User is online!Profile CardPM
+Quote Post

William_Wilson
RE: Downloading That Which Is Not Ussually Downloadable
4 Oct, 2008 - 02:01 PM
Post #2

lost in compilation
Group Icon

Joined: 23 Dec, 2005
Posts: 3,995



Thanked: 16 times
Dream Kudos: 3275
Expert In: Java, C, Javascript

My Contributions
you could create a server side function that created a compressed version of the site, which could contain php files in source version. HTTP itself will not allow the viewing and thus downloading of php source files.

Another option would be to load the files to a database and copy the database, but that seems like a lot of extra work.
User is offlineProfile CardPM
+Quote Post

Andora
RE: Downloading That Which Is Not Ussually Downloadable
4 Oct, 2008 - 06:24 PM
Post #3

D.I.C Head
**

Joined: 18 Aug, 2008
Posts: 105


My Contributions
QUOTE(William_Wilson @ 4 Oct, 2008 - 03:01 PM) *

you could create a server side function that created a compressed version of the site, which could contain php files in source version.
How would this be done? I don't own the server...
QUOTE
Another option would be to load the files to a database and copy the database, but that seems like a lot of extra work.
Hmm... I'm open to whatever but I don't have any experience with databases so that's just way beyond me.

I'm just at a loss. This site will have over 3 new txt files every day and I am worried about my ability to keep backups. Would it simplify things if I only wanted the txt files? sleep.gif
User is online!Profile CardPM
+Quote Post

grimpirate
RE: Downloading That Which Is Not Ussually Downloadable
4 Oct, 2008 - 11:02 PM
Post #4

D.I.C Head
Group Icon

Joined: 3 Aug, 2006
Posts: 191



Thanked: 5 times
Dream Kudos: 375
My Contributions
Your best bet would be like Wilson said. Basically, you could create a server-side script (PHP would be how I'd do it), to recurse through all directories on your server and read every file. It would then compress all the files into one file and finally present the file to you for download.
User is online!Profile CardPM
+Quote Post

baavgai
RE: Downloading That Which Is Not Ussually Downloadable
5 Oct, 2008 - 05:54 AM
Post #5

Dreaming Coder
Group Icon

Joined: 16 Oct, 2007
Posts: 2,031



Thanked: 105 times
Dream Kudos: 475
Expert In: C, C++, Java, C#, ASP.NET, PHP, Perl, Python, Oracle, SQL Server, MySql, HTML, JavaScript, Lua

My Contributions
There are some pure PHP libs for making archives. More here: http://articles.techrepublic.com.com/5100-...11-6161314.html

Here's a little page I wrote ages ago to backup a text based wiki:
php

<?php
$archFile = "dokuwiki.tar.gz";
$dumpFile = "/tmp/dokuwiki.dump.".gmdate("His");
$fullPath = realpath('.');
exec("tar -cz -C .. ".basename($fullPath)." > $dumpFile");
rename($dumpFile, "$fullPath/$archFile");

$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
header("Location: http://$host$uri/$archFile");
exit;
?>


It backups up everything from the parent directory. To avoid stomping on another process, it writes to a tempfile. It then moves the files to a location accessible to the web share and points the browser at it.

Hopefully this gives you some ideas.

User is offlineProfile CardPM
+Quote Post

devonator
RE: Downloading That Which Is Not Ussually Downloadable
5 Oct, 2008 - 06:18 AM
Post #6

New D.I.C Head
*

Joined: 6 Sep, 2008
Posts: 43


My Contributions
you can try xml
User is offlineProfile CardPM
+Quote Post

Andora
RE: Downloading That Which Is Not Ussually Downloadable
8 Oct, 2008 - 08:30 PM
Post #7

D.I.C Head
**

Joined: 18 Aug, 2008
Posts: 105


My Contributions
QUOTE(baavgai @ 5 Oct, 2008 - 06:54 AM) *

There are some pure PHP libs for making archives. More here: http://articles.techrepublic.com.com/5100-...11-6161314.html

Here's a little page I wrote ages ago to backup a text based wiki:
php

<?php
$archFile = "dokuwiki.tar.gz";
$dumpFile = "/tmp/dokuwiki.dump.".gmdate("His");
$fullPath = realpath('.');
exec("tar -cz -C .. ".basename($fullPath)." > $dumpFile");
rename($dumpFile, "$fullPath/$archFile");

$host = $_SERVER['HTTP_HOST'];
$uri = rtrim(dirname($_SERVER['PHP_SELF']), '/\\');
header("Location: http://$host$uri/$archFile");
exit;
?>


It backups up everything from the parent directory. To avoid stomping on another process, it writes to a tempfile. It then moves the files to a location accessible to the web share and points the browser at it.

Hopefully this gives you some ideas.
That is significantly over my head but it sounds very promising. What language is the contents of exec() executed in? I don't recognize that syntax.

And what is the procedure for decompressing it?

This post has been edited by Andora: 8 Oct, 2008 - 08:32 PM
User is online!Profile CardPM
+Quote Post

Andora
RE: Downloading That Which Is Not Ussually Downloadable
19 Oct, 2008 - 12:05 AM
Post #8

D.I.C Head
**

Joined: 18 Aug, 2008
Posts: 105


My Contributions
No help? sad.gif
User is online!Profile CardPM
+Quote Post

baavgai
RE: Downloading That Which Is Not Ussually Downloadable
19 Oct, 2008 - 02:26 AM
Post #9

Dreaming Coder
Group Icon

Joined: 16 Oct, 2007
Posts: 2,031



Thanked: 105 times
Dream Kudos: 475
Expert In: C, C++, Java, C#, ASP.NET, PHP, Perl, Python, Oracle, SQL Server, MySql, HTML, JavaScript, Lua

My Contributions
QUOTE(Andora @ 19 Oct, 2008 - 04:05 AM) *

No help? sad.gif


Sorry, must have missed your response.

The command used in the example I offered is tar. While not common on Windows, it's on almost all *nix boxes and any ISP that supports PHP is likely to have it. The flags here are c for create and z for gzip. It's using a pipe to make sure the output is written to only one particular place. Common alternatives would include zip.

To "untar", the command would be "tar zxf filename". All this is explained exhaustively online. The Tar.php offered by the PEAR library might be simpler.

No matter what you go with, the basics don't really change. Create an archive file on the server system and then point the user's browser at that file. How you choose to do this fairly basic process is up to you.

User is offlineProfile CardPM
+Quote Post

Andora
RE: Downloading That Which Is Not Ussually Downloadable
20 Oct, 2008 - 09:58 PM
Post #10

D.I.C Head
**

Joined: 18 Aug, 2008
Posts: 105


My Contributions
wow, it's been staring me in the face for weeks.

Turns out there are a whole bunch of php functions that will work perfectly for these purposes.

For anyone else having similar troubles: http://us.php.net/manual/en/book.zip.php

Thank you baavgai! biggrin.gif

This post has been edited by Andora: 20 Oct, 2008 - 09:58 PM
User is online!Profile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/3/08 12:14AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month