February 6, 2012

Comments

  1. BrenFM says:

    Hi will!

    Thanks for the tutorial. I had some issues getting this going too – a whole bunch of copy and paste issues on my part, so thought I’d share with the group!

    I needed to make sure I was using the correct – characters. When opening in a text editor I discovered half of them were the long hyphens, not the simple minus sign. Working a treat now, thanks again!

  2. Bonnie Gean says:

    Hi Wil,

    I copied and pasted the tags you have above and created my backup file.

    The only problem is — Auto FTP Manager — found 2 *.gz files on my hostgator account, copied them, and then deleted them. These files were:

    sitemap.xml.gz from my /public_html/ directory and
    wp-tinymce.js from my /wp-includes/js/tinymce/ directory

    LOL, yet it didn’t touch the backup*.gz file that is residing outside the /public_html/ directory.

    How do I fix this? As I followed your instructions to the “T”.

    Thanks for your help!

    – Bonnie

  3. Jane says:

    Thank you for this excellent tutorial. I used this script to setup automatic backups for a site I manage, however, something has stopped working. The last automatic backup I received was November 16th. I use hostgator as well (shared hosting) and out of the blue, I just quit receiving backups. I checked with support & they say that Cron appears to be working fine, and they say the backup.sh looks fine (I didn’t change anything) So I’m wondering if something got changed by hostgator that would cause the backup.sh to become ineffective. I did try changing the permissions to 755 but that didn’t seem to help. I’d appreciate any advise you could give me to get this working again.

    • jwitt98 says:

      I tried this method on Hostgator and also could not get it to work. After some investigation, I found that the newer version of cPanel does not allow http authentication and therefore this method would not work since it relies on http authentication. Is there any workaround that uses POST to authenticate?
      I tried using –keep-session-cookies and –save-cookies cookies.txt, but I’m not versed enough in Linux commands to make it work.

    • Paul says:

      Hey Jane

      Had the same problem.
      - 2 of my Hostgator hosting accounts worked perfectly.
      - 1 stopped working in about October

      Finally got a chance to look at it last week. Just got this response from Hostgator Support.

      ——————-
      I am convinced (wget believer here). I apologize for the delay. I have your script working again. For your script I had to add –auth-no-challenge like so:

      wget -O /dev/null -q –auth-no-challenge –http-user=$1 –http-password=$2 http://localhost:2082/frontend/x3/backup/dofullbackup.html –post-data=”dest=homedir&email=$3″

      The full backups appear to be running successfully. You may want to add that parameter to your others so that they don’t suddenly stop at some point. I don’t know what is different about this particular server. It could be some cPanel updates or something.

      If you need anything else just let us know. We are here to help.

      Best regards,

      Richard B
      Linux Systems Administrator
      HostGator.com LLC
      http://support.hostgator.com

      ——————————————-

      Hope that helps.
      Paul

      • Jane says:

        Paul, thank you so much for this information. I had contacted Hostgator a couple times about this issue and they were never able to tell me anything other than, “the cron looks fine” & “the script looks fine”

        One thing to note is the the text copied from the site here doesn’t work, it includes invalid asci characters. I noticed when trying to update the script that when I saved it it kept defaulting the encoding to “UTF-8″, I was finally able to get it to save as asci and now it’s working again.

        Thank you for taking the time to post your solution!

  4. JosephA says:

    We are using Crucial hosting, they use cpanel but they have turned off the full backup feature. Can you help by providing similar instructions on how to backup a home directory and the individual databases.
    That would be alot of help!

    Thanks

  5. Roger Due says:

    Wilson,
    This is amazing! I listened to your webinar on 7/7/10 hosted by James J Jones and purchased your Easy Redirect Script and have it configured on a new domain I purchased based upon your webinar advice.

    Then I started poking around to see what else you have and found S3FlowShield and then Auto FTP Manager! Then I read the above comments and found some additional info on backing up to Amazon S3.

    I am building websites for myself as well as customers and all of this is very useful. There is always the question of how to systematically do backups and it looks like I now have some good approaches to use.
    – Thanks, Roger

  6. Flavius says:

    I’ve ruin my website with jom sef … so the siteis having some problems…
    I have backup my website exaclty like in this tutorial , i have the backup , if i ask the admin from hostgator to do a restore will hi be able to doi’t ( sorry for my english ) ? or what/how should i ask ? i need help pls …

    If this help someone – it erase the archives older then 6 days …

    find /home/username/ -name ‘backup-*’ -mtime +6 -exec rm {} \;

  7. Shaun Baird says:

    Well this really IS a fantastic link, given to me by your friend May. I have been searching for an answer and it’s only thanks to dedicated people like this that people like us can breathe at night!

    Funny really because some marketers rely on dozens if not hundreds of websites for their full time income, and at any point in time their site and income could be dropped at any time. This HAS happened to me 2 or 3 times in the past years so folks, bite the bullet and just do it.
    Shaun

  8. Malcolm says:

    Excellent. Worked for me first time. No doubt you have saved my life, at some point in the future

  9. Jason says:

    Wow, it finally worked…thank you so much for your help with this. I was wondering….can this script be modified to only backup the public_html folder and NOT the entire home directory? I ask this because Hostgator caps Cpanl backups at 50,000 inodes. I had to whittle my site down a LOT to get it below 50,000. Once a site hosted by Hostgator reaches larger than 50,000 inodes, they wont allow full site backups anymore. So if this script was able to backup only the public_html folder, that would help the size limitation. Can this be done?

    • @Jason,

      This particular method is used for full cPanel backups. You can create a script that only backs up a certain directory and create a cron job to run that on a schedule. That’s pretty simple. The issue is that it will not get the MySQL backups, which the full backup does, so you would have to do something different to get the MySQL backups for each of your databases.

      Wil

  10. Jason says:

    I would be happy to send them to you…but which 2 files…i know you need the backup.sh but what is the other one? Thank you so much for helping me get this going.

  11. @Jason,

    Sorry it is not working for you. A LOT of people have used this procedure and got it working without hitches. I am not sure why it is not working for you. When you create the cron job, are you leaving the double quotes in place? If you want to download and zip the two files (change you password in the files, of course), I will be glad to look at them for you. Just upload the zip file to a web accessible directory and post a link here…(I won’t approve the comment to nobody will see your URL).

    Wil

  12. Jason says:

    That didnt work either, when i did all the copying in IE, it just emailed me a blank email. I think im just gonna give up.

  13. Jason says:

    Let me try using IE instead of Firefox.

  14. Jason says:

    Thats exactly what i did…i copied it directly from this page into the cpanel text editor.

  15. @Jason,

    Make sure the entire script is on one line. Open two browser tabs and copy the script from above and paste it into the editor. Do NOT paste it anywhere else first the copy/paste again.

    Wil

  16. Jason says:

    Ugh…i am SO close i can taste it…been trying to do automated backups for 2 weeks and just cant get it. I think this site is the answer though.

  17. Jason says:

    I am now being emailed this error :

    wget: missing URL
    Usage: wget [OPTION]… [URL]…

    Try `wget –help’ for more options.

  18. @Jason,

    Just use the default setting for character encoding in the cPanel text editor, which is probably UTF-8.

    Wil

  19. Jason says:

    Thanks for the reply, i will try it through the Cpanel text editor…but it is asking what character encoding i want to use and i dont know what to select…sorry, im not a programmer.

  20. @Jason,

    Please copy the scripts again from above and recreate on your server. It looks like my new template messed up the double quotes and I had not noticed. This is probably the issue. They are fixed now.

    Sorry for the trouble you had with it. Let me know how it goes.

    Wil

  21. Jason says:

    I finally got emailed this from the script :

    /home/********/backup.sh: line 1: {rtf1ansiansicpg1252deff0deflang1033{fonttbl{f0fswissfcharset0: command not found
    /home/********/backup.sh: line 1: }}: command not found
    /home/********/backup.sh: line 2: {*generator: command not found
    /home/********/backup.sh: line 2: }viewkind4uc1pardf0fs20: command not found
    /home/********/backup.sh: line 3: syntax error near unexpected token `}’
    /home/********/backup.sh: line 3: `}’

    • @Jason,

      Do what I suggested above (recopying the scripts), but this is a different problem all together. In the video I showed you how to use the file editor in cPanel. It looks to me like you pasted it into MS Word or some other word processor and then uploaded because my script is one single line (not 3) and those commands it is complaining about are control characters that your word processing application is adding in. Please delete the scripts on your server and try again using the cPanel web-based file editor as shown in the video.

      Wil

  22. Jason says:

    I cant get this to work no matter what i try…i followed you instructions perfectly, and the script never executes.

  23. Paul says:

    Hey Will

    Excellent info.
    Q? Will this backup include Add on Domains and/or Subdomains?

    Thanks
    Paul

    • Paul,

      Glad you enjoyed it. To answer your question, yes, this process will back you entire account (including all the data). Since add-on domains are simply folders inside the public_html directory, it will indeed back those up.

      You can see this by downloading the backup file and extracting it on your local machine, so you can see all the data.

      Wil

  24. Eric, thanks for posting a link to your script!

  25. Eric Nagel says:

    So many people think their hosting provider backs up their data… it should be standard, but many have found out the hard way, isn’t.

    I have my FTP or Amazon S3 server backup script available for free on my webiste. It’s configured for GoDaddy, but can be changed for any dedicated server.

  26. @JdotA I see what happened. The problem was with WordPress. It converted the -- into — above, so when you pasted it, it cause the problem. I have hard coded -- in the above example, so this will no longer happen to anyone else. Thanks for the update and congrats on getting this going! Now you can sleep better at night knowing your data is safe!

  27. JdotA says:

    Success!!!! It looks like there were a couple of things causing the backup to fail.

    1st: After I pasted and saved the script into the HostGator text editor, some of the “-” were being auto converted into the ascii code for the symbol “–”. The only ones that actually changed were the first “-” in the following: “–http-user=$1″ , “–http-password=$2″ and in “–post-data=”. So I disabled the auto Disable Character Encoding for the HostGator text editor and then it saved correctly.

    After that I finally started receiving error msgs when the backup was run. I had not been receiving any msgs before this.

    2nd: Once I received the error msgs, I looked up a list of options for wget and realized that I needed to have “–” instead of “-” in front of “–http-user=$1″ , “–http-password=$2″ and in “–post-data=”. Once I made those changes the Backup was successful!

    Thanks for all your help and the tutorial!

  28. @JdotA No, Hostgator does not require any special permissions.

    Can you double check the file name of the script your created? Is the file called backup.sh?

    Is it in the root directory of your account? (at the same level as the public_html directory, not within it, for example)? Can you post a screen shot of your directory somewhere and send me a link on Twitter?

    Also, the filename is case sensitive, as is your username and password.

    Wil

  29. JdotA says:

    @Wil Checked both and they are fine, Username & Password each inside their own set of quotes and email without quotes. The script was copied directly from this page. Does host gator require any special permissions in order to run the scripts?

  30. @JdotA Here are a few things to check:

    1. Did you leave the USERNAME and PASSWORD in the cron command inside quotes? You should surround those values with quotes (the video does not show this, but the example code does). This is required in case you have special characters such as “&,?,” or others in your password.

    2. Did you copy and paste the the backup.sh script exactly as above? The entire script is one single line. If you pasted it elsewhere and used another text editor then uploaded the file, that may be your issue. Make sure you create the file exactly as I showed on the video using cPanel so that there are no special characters (line feeds, carriage returns, etc) in the file. Copy the code, go into the cPanel editor and paste the whole script exactly as it is show in the sample code above.

    Wil

  31. JdotA says:

    After trying a few times, I am still not having much success. The cron job that backup the site is not running no matter what i try. I tested cron by using the mv command above and that worked fine so cron is functioning. Its just not generating the backup. Any other ideas? Thanks.

  32. JdotA says:

    Thanks for all the info. I am setting it up right now, will post the results later today!

  33. @Adam, thanks for the link (click on Adam’s name above).

    Looks like your s3sync solution can easily be used with the tutorial I show here in order to only have 1 file to upload.

    In looking at your script, I learned something VERY cool that I was not aware of….the mysqldump switch to dump all existing databases at once. VERY cool!

    Wil

  34. Adam says:

    I automate my backups to amazon S3 using s3sync. I have a tutorial to it in the url i left ^

  35. @JdotA: Here is what you can do to get around this problem:

    1. Create a folder in the root directory called “backupfolder”

    2. Create a cron job as shown in the video with the following command: mv ~/*.gz backupfolder

    3. Make sure you schedule this for about 30 minutes or so after the backup runs to make sure you backup completes before this runs.

    What this will do is use the Linux/Unix “mv” command to move the backup file from the root directory to the “backupfolder” so your FTP client can just download those files.

    Don’t forget to also remove the files from the server, otherwise you will eventually run out of disk space and if your FTP client is not smart enough to realize that the old files have already been downloaded, each day your downloads will take longer as more files will get downloaded.

    Wil

  36. JdotA says:

    Thanks again for the great info. I am on OSX and I cannot find an app like AutoFTP to pull down a specific file type. I can use Automator to pull the contents of a folder but if I use that, Automator tries to pull all of the files in the home directory. But since HostGator does not let you change the save location I have to try find some other way of doing it. Any info that you might have would be of great help!

  37. Will,

    Excellent job with the explanation. I didn’t realize it was so easy to backup your files. Going to have to try this. Recently I upgraded my phplist through Fantastico, and it caused major havoc. This would have come in handy. I was able to get it restored, but what if I hadn’t.

    Thanks.

Speak Your Mind

*