Proper rsync commands for server migrations

The command rsync -avzu uses rsync, a fast and versatile file synchronization tool. Let’s break down what each option means and an example:
rsync -avzu root@hostname.com:/home/site/public_html/ /usr/share/nginx/sites/site.com/

Flags:

  1. -a (archive mode):
    • Preserves symbolic links, file permissions, modification times, group/owner information, and recursive directory traversal.
    • Essentially, it ensures that the copied files retain their original state as much as possible.
  2. -v (verbose):
    • Displays detailed output about what rsync is doing during the transfer. Useful for tracking the progress and files being synced.
  3. -z (compress):
    • Compresses the data during the transfer to minimize network bandwidth usage, speeding up the process over slow connections.
  4. -u (update):
    • Ensures that only newer files are copied. If the destination has a newer or same timestamp file, it will be skipped, avoiding unnecessary overwrites.