Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I would like to backup the contents of webservers with the least possible effort. Currently, I have a PHP script that gives me a list of the uploaded pictures and I then use wget to download them all via HTTP.

The MySQL data is fetched with a PHP script that dumps the database which I pull with wget over HTTP.

Is there some way to download everything from FTP? So that I can completely mirror the webserver and track any changes?

Sadly, I can only use plain FTP and PHP on the server, I cannot use shell scripts or mysqldump or tar on the server.

share|improve this question
add comment

3 Answers 3

I think you need several pieces of informaiton to rebuild a web server. The html/jpg/script files that are the site, the database data amd the web service config. You might add to that SSl certs, network configs and user info if your site relies on them.

Once you know what you need to rebuild it, how do we get that data? Easiest way is generally from the box that holds the data. Run a script to generate the data, database dump, etc, collect it all into a tar file and ftp off the box.

Alternately, you could run the script as a cron job on the web server, but have your external box come and get the tar file.

share|improve this answer
    
I cannot write a script, I cannot dump the database with mysqldump and I cannot set up a cron job. I can only use FTP and PHP to some extent since it is a hoster's package. –  queueoverflow Jun 8 '11 at 21:17
    
How do you do the mysql dump using PHP? Through PHPMyAdmin? –  uSlackr Jun 8 '11 at 21:20
1  
You should add the bit about not being able to execute a script on the server to the question. its important. –  uSlackr Jun 8 '11 at 21:21
    
I added it. –  queueoverflow Jun 8 '11 at 21:42
add comment

Is there some way to download everything from FTP?

Yes, but you'd need to (or ask someone to) install an ftp server and configure it for you. I'd suggest against this though. FTP sends passwords as cleartext, and as far as I know, there's no common SSL wrapper (like STARTTLS) for it. FTP therefore is a security hole, unless you plan on wrapping in a secure VPN. I suggest using sftp, which is essentially an ssh connection that responds to ftp like commands.

Is this a dynamic server? Does it have PHP or CGI or any other server side code? If so, HTTP requests can only show HTML as the code is run, not the underlying source. This is not a backup. You should backup the source with sftp.

As for MySQL, again, you're not doing a true backup. You should get familiar with mysqldump or find someone to run it for you.

As far as what to do with those files, backing up to git will take some scripting on your part. Usually what people do is backup all files (including your db dump), and keep n days worth. If you backup to source control, now you need to back up your repository and worry about corruption. Usually cleaner to just keep files around. Your source code should be in source control anyway, and it should match what's out on the website.

I personally would feel more comfortable with 'If i untar this file it's my website' rather than 'if my git repository is not gorked i can find the tag for this day and it's my website'. In an emergency situation (and all backup restores are) complexity is not what you want.

share|improve this answer
    
The SCM part is clear, I will not use this but keep using tars. –  queueoverflow Jun 8 '11 at 21:15
    
I claim that I do a complete MySQL backup since my PHP script does a dump. I cannot access mysqldump since it is a hoster's package. They only offer FTP, no encryption -- they are cheap. –  queueoverflow Jun 8 '11 at 21:16
add comment
up vote 0 down vote accepted

To solve the problem that I only have FTP, I finally got a neat solution: curlftpfs and rsync.

# Create a mountpoint for the FTP.
tempdir=$(mktemp -d)
chgrp fuse "$tempdir"
chmod 700 "$tempdir"

# Mount the FTP
curlftpfs "$server" "$tempdir"

# Copy all the new data into the current directory
rsync -avE --delete "$tempdir/$subfolder" "$current"

# Release the mounted FTP
fusermount -u "$tempdir"
rmdir "$tempdir"
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.