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...
Configure pipeline in Buddy
- Create a new project in Buddy and select your Git provider.
Image loading...
- Add a new pipeline and configure the details: name, trigger mode, and a branch from which you want to deploy.
Image loading...
Configure Rsync Deployment
Setting up Rsync deployment in Buddy is straightforward. Follow these steps to configure your action and automate file synchronization:
- Look up and click Rsync on the action list (you can find it in the Deploy & Remote Ops section):
Image loading...
- 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...
- When ready, click Add this action to finish configuration.
Rsync options
The options below can be found in the Rsync tab of the action:
Option | Flag | Description |
---|---|---|
Compress file data during the transfer | -z , --compress | Rsync compresses the file data, which reduces the size of transmitted data. |
Archive mode | -a , --archive | Preserves all information about the file, such as timestamps and permissions. |
Delete extraneous files | --delete | Tells rsync to delete extraneous files from the receiving side. |
Recurse into directories | -r , --recursive | Tells rsync to copy directories recursively. |
Transfer directories without recursing | -d , --dirs | Transfers directories without recursing. |
You can also specify custom options e.g.:
Option | Flag | Description |
---|---|---|
Increased verbosity | -v --verbose | Increases the amount of information provided during the transfer. |
Show progress | --progress | Displays the current progress of the data transfer. |
Save logs to a file | --log-file=FILE | Saves loges to a file specified as FILE . |
Checksums | -c --checksum | Forces 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.
📚 Learn more about rsync action features, integrations and alternatives.
Last modified on Sep 25, 2024