maxbear
07-04-2002, 05:18 PM
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 user@host:/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.
CitadelJon
07-04-2002, 05:38 PM
Use the wget tool ;)
wget --recursive http://www.website.com
or
wget --recursive ftp://ftp.website.com
Hope that helps :)
RRolfe
07-04-2002, 06:31 PM
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.
dannyboy
07-04-2002, 07:09 PM
Since you're using SSH, you might be able to use authorisation keys.
bacid
07-04-2002, 09:31 PM
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..
ho247
07-05-2002, 02:22 AM
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 (http://www.cvm.uiuc.edu/~ms-drake/linux/ssh_nopw.html)".
Alan
admin0
07-05-2002, 08:13 AM
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 root@clientA:/ /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 root@clientA:/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: success@admin0.com
:homer:
maxbear
07-05-2002, 01:49 PM
Hi admin0, really really thanks a lot. It works great. Now I can easy mirror 2 servers. :D
FHJim
07-05-2002, 11:07 PM
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.
:beer:
aquos
07-06-2002, 01:04 AM
Does it work if you have MySQL database?
maxbear
07-06-2002, 03:07 AM
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/
apollo
07-06-2002, 03:02 PM
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