post-page

WP Backup to Email Script

10
responses
by
 
on
March 8th, 2005
in
Cool Scripts, WordPress Hack

Ever since Geoff wrote the small script to backup a WordPress installation automatically, I have wanted to make his script email me with the backups once they are done. So I modified the original script to email a given address with the backup files (the backup files are deleted from the server once the email is sent)

I ran into some problems while running the script on my own server because of the sheer size of the backups. I rewrote it to FTP the backups to another server to prevent killing my mail server. However, smaller installations (anything less than 500 megs) would benefit from the email backup and I decided to release the code.

You can download the script from here, copy it to a location on your drive that would allow execution, give it execute permissions (chmod 755 backupwp.sh) and then write a small cron entry that runs this however often you wish.

Once the script is uploaded, you will also need to modify the server variables for your own blog. They are in the first half of the script and I have tried to make them as self explanatory as possible.

Some caveats include:
Has to be a Linux/UN*X box
Backups CAN get huge and can slow down your server, depending on load/size of the blog
You have to have ssh/command line access to your server, I guess just cron access would work as well

There are various cron tutorials on the web for your perusal. If you do not want to be emailed with the output from the script, just add a ” >/dev/null 2>&1″ at the end of the cron entry.

Please post bugs/suggestions. This has been sparingly tested and comes with no gaurantees or promises. Please use at your own risk and I am not be responsible for any damage caused by this script. Thanks goes to Geoff Morris for writing the original set.

heading
heading
10
Responses

 

Comments

  1. Geof F. Morris (19 comments.) says:

    Mark, this is elegant. I love it!

  2. Dave M. (1 comments.) says:

    My site isn’t huge, but I don’t have permission to use ‘mail’. Any chance you could send me the ftp version of your script? I’ve got Filezilla server up and running here, so I just need a way to ftp to it.

    I’m not sure what I need to do if anything to make sure that ftp log’s in correctly. I see in the ftp man pages that a .netrc file needs to be available, but I’m not sure what needs to be in that file for it to work.

  3. Nick (11 comments.) says:

    Hey Mark,
    This sounds awesome, but I can’t get the script to run. At first I was getting an error about options, so I removed the “-f” from the first line of the script. Now I’m getting
    “: bad interpreter: No such file or directory”

  4. Mark (118 comments.) says:

    Do a search for bash on your server (which bash) and replace the path on the first line. :) Sorry, I didnt see these comments.

  5. Nick (11 comments.) says:

    It’s the same as the path in the script.
    /bin/bash

  6. Mark (118 comments.) says:

    Hmmm…make sure you can type in “/bin/bash” at the command prompt and bash gets loaded.

  7. Nick (11 comments.) says:

    Yup, that loads bash.

  8. Mark (118 comments.) says:

    Hmmm…this might need a little human interference. :)
    Can you email me with some more details?

  9. Manish Gupta says:

    Still not able to make the script work. Getting:

    : bad interpreter: No such file or directory

    Where you able to solve Mark’s problem. I was wondering you can help me. Many thanks in advance.



Trackbacks/Pingbacks

  1. […] Gelukkig heb ik SSH toegang, zodat je een scriptje kan gebruiken. Gisterenavond vond ik een prachtig script op een backup te neme […]

Obviously Powered by WordPress. © 2003-2013

page counter
css.php