1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Automated website backup

Discussion in 'HTML, Graphics & Programming' started by Tunney, 16 Jan 2006.

  1. Tunney

    Capodecina

    Joined: 11 Oct 2004

    Posts: 14,550

    Location: London

    At the moment, I've got a blog running WordPress 2.0 on my website. I've set WordPress up to e-mail me a back-up of the mySQL database every day. This then goes to my gmail e-mail account where it's archived. It works well so I'm wondering about how to backup the other files used in my blog via an automated process to a local drive.

    What do people recommend? Is there a simple way to schedule an ftp download under Windows? Would compressing and e-mailing an entire website (100-200MB) using a cron job be feasible? Is there any software out there that makes scheduled backups easy?

    Cheers!
     
  2. zetec452

    Sgarrista

    Joined: 15 Sep 2003

    Posts: 9,454

    What control panel does your webhost run? Most of them will have a backup feature that you can use.
     
  3. toastyman

    Gangster

    Joined: 30 Dec 2005

    Posts: 421

    Possibly set up a connection with another computer...say yours at home, and every night, if your computer is on, do the backup via FTP or a similar protocol. If your computer isn't on, send it via email.
     
  4. Tunney

    Capodecina

    Joined: 11 Oct 2004

    Posts: 14,550

    Location: London

    Is there software that will automate this for me? Something that will sit in the system tray of my home machine perhaps?
     
  5. toastyman

    Gangster

    Joined: 30 Dec 2005

    Posts: 421

    Do you have full access to the server and what OS is it running?
     
  6. Tunney

    Capodecina

    Joined: 11 Oct 2004

    Posts: 14,550

    Location: London

    I don't think that my access is full, but I've got enough access to set-up cron jobs and use various server-side software over ssh. The server is running Linux.
     
  7. toastyman

    Gangster

    Joined: 30 Dec 2005

    Posts: 421

    There are backup tools out there on the internet for backing up Linux to Windows...but you wouldn't be able to use that because your host wouldn't let you install it.

    However, you can set it up using PHP...look up on google how php can open an FTP session and transfer files...then you could use a cron job to schedule this every night.
     
  8. toastyman

    Gangster

    Joined: 30 Dec 2005

    Posts: 421

    Straight off the PHP site.
    PHP:
    <?php
    // set up basic connection
    $conn_id ftp_connect($ftp_server);

    // login with username and password
    $login_result ftp_login($conn_id$ftp_user_name$ftp_user_pass);

    // check connection
    if ((!$conn_id) || (!$login_result)) {
           echo 
    "FTP connection has failed!";
           echo 
    "Attempted to connect to $ftp_server for user $ftp_user_name";
           exit;
       } else {
           echo 
    "Connected to $ftp_server, for user $ftp_user_name";
       }

    // upload the file
    $upload ftp_put($conn_id$destination_file$source_fileFTP_BINARY);

    // check upload status
    if (!$upload) {
           echo 
    "FTP upload has failed!";
       } else {
           echo 
    "Uploaded $source_file to $ftp_server as $destination_file";
       }

    // close the FTP stream
    ftp_close($conn_id);
    ?>