The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

I need help modifying my backup script

Discussion in 'General Discussion' started by dianaward, Sep 16, 2004.

  1. dianaward

    dianaward Well-Known Member

    Joined:
    Dec 9, 2002
    Messages:
    99
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    USA
    cPanel Access Level:
    Root Administrator
    Twitter:
    I have been using a script to daily, weekly and monthly ftp the automatic backups my web hosting servers to a different server for redundant backups. It has been working fine, but due to a couple of website hackings on my servers I have recently stopped allowing root login on them. The problem is that I am not very familiar with writing unix scripts and I'm not sure how to change my backup ftp scripts so that they will log into the receiving server as admin and then su root, then enter the root password. Can someone please help?
     
  2. dianaward

    dianaward Well-Known Member

    Joined:
    Dec 9, 2002
    Messages:
    99
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    USA
    cPanel Access Level:
    Root Administrator
    Twitter:
    Help meeeeee?????

    I know many of you can write shell scripts. All I need is to know how the commands should look, I think....
     
  3. GaryW

    GaryW Active Member

    Joined:
    Apr 27, 2004
    Messages:
    31
    Likes Received:
    0
    Trophy Points:
    6
    Interesting script - how could I do something similiar to this?
     
  4. dianaward

    dianaward Well-Known Member

    Joined:
    Dec 9, 2002
    Messages:
    99
    Likes Received:
    0
    Trophy Points:
    6
    Location:
    USA
    cPanel Access Level:
    Root Administrator
    Twitter:
    Here's the basic script:

    Script starts below:


    #!/usr/bin/expect -f

    set root_pass "xxxxxxxxx"
    set hostname "123.45.678.910"

    set folder "/backup/cpbackup/daily"

    spawn /usr/bin/scp -r $folder root@$hostname:/backup/daily
    sleep 3
    expect "password: "
    sleep 3
    send "$root_pass\r"
    interact

    Script ends. Put in /usr/bin/ and name whatever you'll remember. Chmod 755.

    Change root pass to the root password on the receiving server, hostname to the receiving IP, "set folder" to the location of the backup files on the sending server, and "/backup/daily to the location you want the files sent.

    I created an scpeweekly.sh and scpemonthly.sh to send those too. I set up cron jobs to do them automatically, but for some reason the crons don't usually work, so I just executed the scripts manually.

    Of course, now I can't use them until I find some help making the script login as admin and su root.
     
Loading...

Share This Page