Blog

How to transfer files over servers flawlessly.

If you followed the previous tutorial, you’d know how to transfer files over servers without passwords.

So to transfer a file from server to server issue the following command (USING SCP).

scp /path/to/my.file me@otherserver(link sends e-mail):/path/to/destination/my.file

Now the same using Rsync:

# apt-get install rsync

Or

# apt-get install rsync

Commands:

  • –delete : delete files that don’t exist on sender (system)
  • -v : Verbose (try -vv for more detailed information)
  • -e “ssh options” : specify the ssh as remote shell
  • -a : archive mode
  • -r : recurse into directories
  • -z : compress file data

Now copy to remote server:

Copy file from /www/backup.tar.gz to a remote server called new.in

$ rsync -v -e ssh /www/backup.tar.gz user@new.in(link sends e-mail):~

Output:

Password:
sent 19099 bytes  received 36 bytes  1093.43 bytes/sec
total size is 19014  speedup is 0.99

Copy file /home/user/webroot.txt from a remote server new.in to a local computer’s /tmp directory:

rsync -v -e ssh user@new.in (link sends e-mail):~/webroot.txt /tmp

Synchronize a local directory with a remote directory

rsync -r -a -v -e "ssh -l user" --delete /local/webroot new.in:/webroot

Synchronize a remote directory with a local directory

rsync -r -a -v -e "ssh -l user" --delete new.in:/webroot/ /local/webroot

Synchronize a local directory with a remote rsync server or vise-versa

rsync -r -a -v --delete rsync://new.in/cvs /home/cvs

Mirror a directory between my “old” and “new” web server/ftp

rsync -zavrR --delete --links --rsh="ssh -l user" my.old.server.com:/home/lighttpd /home/lighttpd

That pretty much summarizes everything you’ll need to do with files locally and remotely.

ddemuro
administrator

Sr. Software Engineer with over 10 years of experience. Hobbist photographer and mechanic. Tinkering soul in an endeavor to better understand this world. Love traveling, drinking coffee, and investments.

You may also like

Compiling Qemu-KVM

Leave a Reply

%d bloggers like this: