1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Trying to write an automatic backup script.

Discussion in 'Web Design & Development' started by Katzy, Jan 26, 2006.

Thread Status:
Not open for further replies.
Advertisement
  1. Katzy

    Katzy Thread Starter

    Joined:
    Nov 9, 2003
    Messages:
    563
    I'm trying to do this by setting-up a cronjob, with the following script:

    echo "Backing your public_html directory..."

    tar -cvjf wwwbackup.tbz public_html

    echo "Done."


    Trouble is, although I worte the script in emacs, I'm getting an error saying that "/public_html\r doesn't exist".

    Eh?

    It certainly DOES exist, but where's the "\r" bit coming from?

    I'd done the script in "Texpad", so I thought it might be producing a linefeed. I wrote it in emacs, too, though, and it's giving me the same error.

    Weird.

    Any ideas, pretty-please? This has been driving me mental!
     
  2. Rockn

    Rockn

    Joined:
    Jul 29, 2001
    Messages:
    21,334
    Don't you need to specify the drive and prtition along with the path?
     
  3. Katzy

    Katzy Thread Starter

    Joined:
    Nov 9, 2003
    Messages:
    563
    There is no drive or partition, because it's a website.

    The script is in the root of the site, in the same place as "public_html" is.

    This has been driving me mental, for weeks!
     
  4. Squashman

    Squashman Trusted Advisor

    Joined:
    Apr 4, 2003
    Messages:
    19,786
  5. Katzy

    Katzy Thread Starter

    Joined:
    Nov 9, 2003
    Messages:
    563
    Nope. Both have the underscore between "public" and "html".

    It's that weird "\r". I just can't see where it's coming from.

    Weird.
     
  6. Squashman

    Squashman Trusted Advisor

    Joined:
    Apr 4, 2003
    Messages:
    19,786
    Why would you put the script in Public_html? Wouldn't it make more sense to put it in the parent directory and backup the public_html folder from there.
     
  7. Katzy

    Katzy Thread Starter

    Joined:
    Nov 9, 2003
    Messages:
    563
    As I said in my original post, "The script is in the root of the site, in the same place as "public_html" is."

    Not IN the public_html.
     
  8. brendandonhu

    brendandonhu

    Joined:
    Jul 8, 2002
    Messages:
    14,681
    Are you uploading this script through FTP? You might need to change the transfer mode ("Binary" and "ASCII", you can try both and see if either works.)
     
  9. Katzy

    Katzy Thread Starter

    Joined:
    Nov 9, 2003
    Messages:
    563
    I hadn't thought of that...:p

    I'll give it a try.

    Thanks!
     
  10. brendandonhu

    brendandonhu

    Joined:
    Jul 8, 2002
    Messages:
    14,681
    Might work, especially if you're uploading from Windows->*nix or *nix->Windows since the linefeeds tend to get messed up.
     
  11. Katzy

    Katzy Thread Starter

    Joined:
    Nov 9, 2003
    Messages:
    563
    Yeah. As I said, I'd done the script in "Texpad", so I thought it might be producing a linefeed. I wrote it in emacs, too, though, and it's giving me the same error.

    I just tried binary and there's something happening, which is an improvement.

    Whilst I'm here, how would I modify that script, to get it to add the date to the archive name and e-mail the backup, to myself?

    I'm about to try and research that bit, but I thought it worth asking the experts, first. ;)

    Thanks, again.

    Much appreciated.
     
  12. brendandonhu

    brendandonhu

    Joined:
    Jul 8, 2002
    Messages:
    14,681
    I'm not sure, you might try the UNIX/Linux forum.
     
  13. Squashman

    Squashman Trusted Advisor

    Joined:
    Apr 4, 2003
    Messages:
    19,786
    Ok, I understand. Root of the site means Public_html to me. You could have just said it was in your home directory. That would have made more sense to Unix people.

    This is how I create my filenames for scripts I write that need the date. I create one variable with the date and another for the full filename.

    DATEPART=`date +-run-%Y-%m-%d`
    FILENAME=Backup$DATEPART.txt

    So the actuall filename is Backup-run-2006-01-29.txt

    I will get the mail thing figured out for you in a second. Gotta look something up.
     
  14. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/437380

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice