Results 1 to 13 of 13

Thread: rsync question

  1. #1
    Join Date
    Jun 2001
    Posts
    430

    rsync question

    Hi all,

    I am trying to use rsync to mirror a web site between 2 servers. It works great so far.

    I use the following command to mirror the web site.

    rsync -e ssh -avz --delete [email protected]:/sourcedir /densir

    It asks me the remote server password every time.

    Does anybody know how can I rsync without manually enter remote server password? Becasue I want to rsync through crontab. Crontab won't let you manually enter remote server password.

    Thanks for any help.

  2. #2
    Use the wget tool

    wget --recursive http://www.website.com

    or

    wget --recursive ftp://ftp.website.com

    Hope that helps

  3. #3
    you enter the password into a password file (just a text file with the password on the first line) and then you add the password file switch the the rsync command. i forgot what the switch is but you can get it by typing "man rsync" into the console.

  4. #4
    Since you're using SSH, you might be able to use authorisation keys.

  5. #5
    on the source box you are using rsync setup the user to have a ssh key , then on the target box create the same user and add the key to authorized_keys

    this is a pretty secure method..

  6. #6
    Join Date
    Aug 2001
    Location
    United kingdom
    Posts
    1,003
    As two members have mentioned above, using authorisation keys will allow you to access the remote server without a password. Take a look at the instructions to set this up... "How to Use SSH Without a Password".

    Alan
    Alan Ho
    Former Systems Administrator

  7. #7
    Join Date
    Dec 2001
    Location
    Netherlands
    Posts
    780
    This works [admin0 recommended!]


    Backup Server:

    $ su -
    # ssh-keygen -t dsa
    ENTER <for path>
    ENTER <for blank password>

    This will create
    ~root/.ssh/id.dsa
    ~root/.ssh/id.dsa.pub

    # scp ~root/.ssh/id_dsa.pub clientA:~root/.ssh/authorized_keys2
    < enter root password for clientA >

    # ssh-agent sh -c 'ssh-add < /dev/null && bash'

    Test Success:
    # ssh clientA -- no password needed !!! instant access !!
    Logout, since we plan to run rsync.

    rsync -avz -e ssh [email protected]:/ /backup/clientA/ >> log.clientA 2>&1 -- this will backup the whole system! -- see below for site


    for making things easy, create a backup.sh file.



    ---------------

    #!/bin/sh
    rsync -avz -e ssh [email protected]:/path/to/website /backup/path/to/backupsite/ >> log.clientA 2>&1

    ---------------




    and in crontab, run as

    * * root /path/backup.sh

    or via console, path/backup.sh &




    email success to: [email protected]

    Last edited by admin0; 07-05-2002 at 08:24 AM.
    Experienced OpenStack Admin For Hire
    regular as admin0 on freenode IRC on #openstack and #openstack-ansible channels

  8. #8
    Join Date
    Jun 2001
    Posts
    430
    Hi admin0, really really thanks a lot. It works great. Now I can easy mirror 2 servers.
    http://www.ebookeasy.com Free ebook for webhosting and dedicated server review

  9. #9
    Join Date
    Dec 2001
    Location
    Netherlands
    Posts
    780


    Experienced OpenStack Admin For Hire
    regular as admin0 on freenode IRC on #openstack and #openstack-ansible channels

  10. #10
    Join Date
    Jun 2002
    Location
    Australia & The Pacific
    Posts
    75
    By the way, if you use a blank passphrase when generating the private/public key using ssh-keygen, you don't need to deal with / use ssh-agent.


  11. #11
    Join Date
    Jun 2002
    Posts
    80

    *

    Does it work if you have MySQL database?

  12. #12
    Join Date
    Jun 2001
    Posts
    430
    Yes, i think so.

    Change the /sourcedir to your mysql directory and it will work too.

    But there are also other scripts which can backup mysql. Like this:

    http://web.abumami.com/
    http://www.ebookeasy.com Free ebook for webhosting and dedicated server review

  13. #13
    for mysql you should check out mysql web site. there are different ways to backup and replicate mysql database data between multiple servers

    http://www.mysql.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •