>Root user is disabled by default, try using sudo.
1. Make sure that both computers have a static ip address and that they are both listed in the /etc/hosts file. 2. Use the following procedure to generate a public/private key on the computer that will act as the backup machine (server): a) login to the machine to be backup as root. On mac-machines you will need to use the terminal mode to set the root password, as administrator do the following: sudo passwd root b) Use ssh-keygen to generate your public and private keys. The following is a ssh-keygen example: [root@ed-karen root]# ssh-keygen -b 1024 -t dsa Generating public/private dsa key pair. Enter file in which to save the key (/root/.ssh/id_dsa): Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/.ssh/id_dsa. Your public key has been saved in /root/.ssh/id_dsa.pub. The key fingerprint is: 9d:10:3b:1f:40:1b:d7:bd:e9:32:0f:4d:04:c1:0e:fb root@ed-karen.com [root@ed-karen root]# cd /root/.ssh [root@ed-karen .ssh]# ls id_dsa id_dsa.pub known_hosts [root@ed-karen .ssh]# cp id_dsa.pub root_ed-karen.pub [root@ed-karen .ssh]# ls root_ed-karen.pub id_dsa id_dsa.pub known_hosts [root@ed-karen .ssh]# scp root_ed-karen.pub node2:/root/.ssh/authorized_keys root@node2's password: root_ed-karen.pub 100% |*****************************| 606 00:00 SSH login to node2 is now allowed without password [root@ed-karen .ssh]# ssh node2 root@node2:# return to your root@node2:# exit ********************* The backup Script ********************* #!/bin/sh # A script to use rsync to backup a directory to a remote # server. See: http://ed-karen.com/mac-help.html for specifics. # This script might be put in cron.hourly or cron.daily to # preform it;s tasks. (efa) 8/27/03 # Destination host machine name DEST="node2" # User that rsync will connect as # Are you sure that you want to run as root, though? USER="root" # Directory to copy from on the source machine. BACKDIR="/home/" # Directory to copy to on the destination machine. DESTDIR="/save/home/" # excludes file - Contains wildcard patterns of files to exclude. # i.e., *~, *.bak, etc. One "pattern" per line. # You must create this file. # EXCLUDES=/root/bin/excludes # Options. # -n Don't do any copying, but display what rsync *would* copy. For testing. # -a Archive. Mainly propogate file permissions, ownership, timestamp, etc. # -u Update. Don't copy file if file on destination is newer. # -v Verbose -vv More verbose. -vvv Even more verbose. # See man rsync for other options. # For testing. Only displays what rsync *would* do and does no actual copying. #OPTS="-n -vv -u -a --rsh=ssh --exclude-from=$EXCLUDES --stats --progress" # Does copy, but still gives a verbose display of what it is doing #OPTS="-v -u -a --rsh=ssh --exclude-from=$EXCLUDES --stats" # Copies and does no display at all. #OPTS="--archive --update --rsh=ssh --exclude-from=$EXCLUDES --quiet" # Copies, deletes old files, no excludes and does no display at all. OPTS="--delete --archive --update --rsh=ssh --quiet" # May be needed if run by cron? export PATH=$PATH:/bin:/usr/bin:/usr/local/bin # Only run rsync if $DEST responds (remote machine is connected to internet and on). VAR=`ping -s 1 -c 1 $DEST > /dev/null; echo $?` if [ $VAR -eq 0 ]; then rsync $OPTS $BACKDIR $USER@$DEST:$DESTDIR else echo "Backup_dirs cannot connect to $DEST." echo "*** Backup aborted ***" fi #if you have many directories you might use the following #type rsync instead (simpler). # Only run rsync if $DEST responds (do /var/www/cgi-bin directory). #VAR=`ping -s 1 -c 1 $DEST > /dev/null; echo $?` #if [ $VAR -eq 0 ]; then # rsync $OPTS /var/www/cgi-bin/ $USER@$DEST:/save/www/cgi-bin/ #fi |