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