Posts

Showing posts with the label rsync

Passing password to the rsync command with sshpass

In some cases, when writing a bash shell script like running the rsync command multiple times, and you want to avoid entering username and password over and over again, you may find sshpass useful. $ sudo apt-get install sshpass Example script: #! /bin/bash for oldblogid in `cat $1` do         media=/var/www/wp-content/blogs.dir/$oldblogid           echo "=== Checking the existance of $media directory..."                                                                                                if [ -d "$media" ]          then                 echo "    Existed! Copying $media..."           ...

Shell - Copying file from remote server to local machine

Sometime you want to copy something (files) from your remote server to your local machine. The thing is, the remote server is the only one that has ssh, so you can only push file to it (remote one) through scp command. I found the rsync command that solves the problem: (type this in your local machine's terminal) rsync -chavzP --stats user@remote.host:/path/to/copy /path/to/local/storage