Synchronize files with Rsync

Synchronizing files across servers can be efficiently handled using Rsync, especially when integrated with Buddy CI/CD. This guide will walk you through setting up and automating Rsync deployments, ensuring your files are always securely managed and up-to-date.

What is Rsync ?

Rsync (Remote Sync) is an open-source tool that enables quick and effective file transfer and synchronization between different locations - both local and remote. It uses a delta algorithm that compares the modification times and sizes of files, helping to minimize network usage and speed up the synchronization.

The tool is often used for backups and updating the content of websites, but there’s much more you can achieve with it. Integrating it with Buddy lets you automate Rsync tasks, which increases the efficiency of your pipeline.

Image loading...Example pipeline with Rsync file synchronization

Tip
If you are new to Buddy, check out our workflow guides that will tell you how to create build, test and deploy your type of application.

Configure pipeline in Buddy

  1. Create a new project in Buddy and select your Git provider.

Image loading...Creating a new project

  1. Add a new pipeline and configure the details: name, trigger mode, and a branch from which you want to deploy.

Image loading...Adding a new pipeline

Configure Rsync Deployment

Setting up Rsync deployment in Buddy is straightforward. Follow these steps to configure your action and automate file synchronization:

  1. Look up and click Rsync on the action list (you can find it in the Deploy & Remote Ops section):

Image loading...Remote actions in Buddy

  1. The action has five configuration tabs:
  • Rsync – here you select the source path, adjust recursion and compression parameters, and define files to ignore
  • Target – here you provide the data of the server with which you want to synchronize
  • Variables - here you can save server credentials as environment variables for increased security
  • Conditions – here you configure the trigger conditions for which the action will run
  • Options – here you define the action's name and behavior on failure and timeout

Image loading...Rsync action configuration

  1. When ready, click Add this action to finish configuration.
Hint
Read how to configure Rsync with YAML and Rsync POST Parameters.

Rsync options

The options below can be found in the Rsync tab of the action:

OptionFlagDescription
Compress file data during the transfer-z, --compressRsync compresses the file data, which reduces the size of transmitted data.
Archive mode-a, --archivePreserves all information about the file, such as timestamps and permissions.
Delete extraneous files--deleteTells rsync to delete extraneous files from the receiving side.
Recurse into directories-r, --recursiveTells rsync to copy directories recursively.
Transfer directories without recursing-d, --dirsTransfers directories without recursing.

You can also specify custom options e.g.:

OptionFlagDescription
Increased verbosity-v --verboseIncreases the amount of information provided during the transfer.
Show progress--progressDisplays the current progress of the data transfer.
Save logs to a file--log-file=FILESaves loges to a file specified as FILE.
Checksums-c --checksumForces the use of checksums, ensuring more accurate synchronization than just comparing file modification time and size.

Congratulations! 🥳 You have successfully configured your deployment, and you’re now ready to transfer files with the Rsync action. Consider expanding your pipeline by adding other actions available in Buddy that suit your tech stack. Make use of our build actions to build your application and test it before deployment.

Hint

📚 Learn more about rsync action features, integrations and alternatives.

Last modified on Sep 25, 2024