Using RSYNC to update local files - can this be improved?

I run Ubuntu 20.04 locally and have VPS mirror images of numerous websites.

In order to simplify updating from localhost to online servers I have the following Command Line alias:

alias upci4="rsync  -avz /var/www/domainName.tld/   -e ssh root@123.45.67.89:/var/www/domainName.tld/"

After localhost modifications “upci4” is called from the Command Line, followed by the password. Only modified files are updated and they are even zipped then unzipped remotely. Updates takes seconds :slight_smile:

It certainly beats using FileZilla and is far, far quicker.

I’m curious to know if this technique could be improved.

You say servers, plural. Are you uploading the same code to one server or multiple?

If it’s one I don’t see how you can improve on this. If it’s multiple you might look into Ansible to orchestrate the upload to multiple servers at the same time.

1 Like

Many thanks for the suggestions. I checked Ansible and do not think it is necessary since I only have one VPS server.

Eventually I struggled through the confusing documentation concerning using SSH. I managed to call the Ubuntu Commands without having to repeatedly type in the password.

I also modified /home/john/.bashrc with the following changes:

# ========================================================
# UPload 
# ========================================================
  alias upican="rsync  -avz /var/www/url-001.tld/   -e ssh root@123.45.67.89:/var/www/url-001.tld/"
  alias upci4="rsync    -avz /var/www/url-002.tld/   -e ssh root@123.45.67.89:/var/www/url-002.tld/"

  clear
    printf "\t upican   \n"  
    printf "\t upci4    \n"  

# REFRESH ALIAS
  alias refresh="source ~/.bashrc"

Calling the Ubuntu Command and I am now presented with the following:
Screenshot from 2021-06-15 09-39-03

Typing the command upican and the localhost is now rsynced with the online server. Works a treat :slight_smile:

Nice, I like the refresh alias too. I might to “borrow” that from you :slight_smile:

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.