Web Niraj
  • Facebook
  • Flickr
  • Github
  • Linkedin
  • Twitter
  • YouTube
Online portfolio, code examples and developer blog
  • About
  • Contact
  • Portfolio
  • WordPress
Search the site...
  • Home
  • Blog
  • Syncing Servers using Rsync

Syncing Servers using Rsync

0

A while ago I had to sync files from one server to another. The reason? I was responsible for moving all the application and websites hosted on a old server to a new, faster server with better security and a updated operating system. Since the servers were remote, I couldn’t simply use a USB drive and transfer the files from one server to another.

Instead, I used a handy unix command line tool called rsync. It let me copy all the files I needed from one server to another over SSH. The command line I used was:

The basic rsync command can be used to copy files from one folder to another. I also find it particularly useful to remove SVN directories from my source code, before sending it to clients. This is a typical command:

The r flag is used to recursively copy folders, so entire folder structures can be copied effortlessly. The r flag can be left out if only files need to be copied. The v flag is used to output the list of files and folders that are being copied so you can see the progress in real-time.

The z flag compresses the transfer, useful if you have bandwidth limits to stick to when transferring data over the internet. The u flag only copied updated files that were changed since the last sync – this makes it easier to keep files up-to-date between servers (providing that files didn’t change on the destination server).

Linux, Server

Leave a ReplyCancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

StackExchange / StackOverflow

profile for Niraj Shah on Stack Exchange, a network of free, community-driven Q&A sites

Support Me

Buy Me a Coffee

PSN Profile

Tags

ACL Amazon Amazon Web Services Android Android 4.4 KitKat Android 5.0 Lollipop Apache Backup Bug Command Line Cordova cPanel / WHM Facebook Facebook Graph API Facebook PHP SDK 4.0 Facebook Social Plugins Fan Page Firewall Flash Gadget Geolocation Google Nexus 5 Hacking HTML5 iOS JavaScript jQuery Laravel 5 Linux NodeJS Parse PDF PHP Plugin Portfolio PS4 Review Security Server SSH SSL Sysadmin Tutorial WordPress WordPress Plugins
© 2011-2025 Niraj Shah
  • Blog
  • Portfolio
  • WordPress
  • About Me
  • Contact Me
  • Privacy Policy
Privacy & Cookies: This site uses cookies. By continuing to use this website, you agree to their use.
To find out more, including how to control cookies, see here: Privacy Policy