You need to setup password less login using ssh keys; refer to following tutorials:
+ Howto Linux / UNIX setup SSH with DSA public key authentication (password less login)
+ SSH Public key based authentication - Howto
#!/bin/bash # Remote Server Rsync backup Replication Shell Script # ------------------------------------------------------------------------- # Copyright (c) 2005 nixCraft project <http://cyberciti.biz/fb/> # This script is licensed under GNU GPL version 2.0 or above # ------------------------------------------------------------------------- # This script is part of nixCraft shell script collection (NSSC) # Visit http://bash.cyberciti.biz/ for more information. # ------------------------------------------------------------------------- # Local dir location LOCALBAKPOINT=/disk3 LOCALBAKDIR=/remote/home/httpd/ # remote ssh server # user SSHUER=brootbeer # server IP / host SSHSERVER=10.10.11.12 #remote dir to backup SSHBACKUPROOT=/disk2.backup/hot/ rsync --exclude '*access.log*' --exclude '*error.log*' -avz -e 'ssh ' ${SSHUER}@${SSHSERVER}:${SSHBACKUPROOT} ${LOCALBAKPOINT}${LOCALBAKDIR} # log if backup failed or not to /var/log/messages file [ $? -eq 0 ] && logger 'RSYNC BACKUP : Done' || logger 'RSYNC BACKUP : FAILED!' # Replicate backup to /disk1 and /disk2 # You can also use format user@host:/path # refer to rsync man page SRC=${LOCALBAKPOINT}${LOCALBAKDIR} DST="/disk1/remote /disk2/remote" for d in $DST do [ ! -d $d ] && mkdir -p $d || : rsync -avr $SRC $d done
Featured Articles:
- 20 Linux System Monitoring Tools Every SysAdmin Should Know
- 20 Linux Server Hardening Security Tips
- 10 Greatest Open Source Software Of 2009
- My 10 UNIX Command Line Mistakes
- Top 5 Email Client For Linux, Mac OS X, and Windows Users
- Top 20 OpenSSH Server Best Security Practices
- Top 10 Open Source Web-Based Project Management Software
- Top 5 Linux Video Editor Software
Want to read Linux tips and tricks, but don't have time to check our blog everyday? Subscribe to our email newsletter to make sure you don't miss a single tip/tricks.
- Download Script
- Email this to a friend
- Rss Feed
- Last Updated: 04/24/08
{ 1 trackback }
{ 0 comments… add one now }