You decide which services we may enable for analytics, personalization, and external content.
We use cookies and similar technologies on our website to personalize content, embed external media, and better understand how individual areas are used.
Necessary cookies
These entries support essential functions such as security, stability, and form processing.
Optional sections
AnalyticsMarketingPersonalizationExternal media
Your data may be processed with your consent or on the basis of legitimate interests. In the cookie settings, you can reject or explicitly allow each optional category.
Some services process personal data in third countries. By consenting, you also agree to this transfer. You can find more information in our Privacy Policy.
You can reopen and change your selection at any time. · 1.0.2
Learn how to create efficient incremental backups with Rsync for local or remote data synchronization → Find out more
10 November 20264 min read1 Views0 helpful
Rsync:
You can use the Rsync tool to create backups.
You can copy data locally to another directory or drive on the system, or to a remote system.
FAQ
Frequently asked questions
Run the command 'apt install rsync'.
Rsync synchronizes all data the first time. From the second run onward, it transfers only changed data, creating an incremental backup.
Run 'rsync -arz /home/Client /home/Backup'. The flags stand for archive mode (-a), recursive (-r), and compression (-z).
Add the --delete parameter: 'rsync -arz --delete /home/Client /home/Backup'. This removes files from the Backup folder if they no longer exist in the source.
Yes. Add the command to a cron job, for example using 'crontab -e'.
Feedback
Was this article helpful?
Your feedback helps us prioritize and improve content.
0 of 0 Users found this article helpful.
Personal support
Need more help than the guide provides?
Our ZAP support team knows your product — briefly describe your issue and we'll help you personally.
Navigation
VPS
Copy data to another local directory or drive:
Info
Note: Depending on the amount of data, the first run may take significantly longer than subsequent runs. This is because Rsync synchronizes all data the first time; from the second run onward, only changed data is transferred.
This creates an incremental backup.
Step 1
You can install Rsync with the following command:
Code
apt install rsync
Once installed, you can use it right away.
Step 2
In this example, the Client folder in /home is synchronized with the Backup folder in /home.
Use the following command:
Code
rsync -arz /home/Client /home/Backup
-a=Archive mode; copies all attributes
-r=Recursive; also synchronizes subfolders
-z=Compression; data is compressed depending on the amount and size of the data
The folder was successfully synchronized.
If a file, etc. is deleted from the Client folder, it remains in the Backup folder.
However, if the files should always be identical, you can modify the rsync command so that data no longer present in the Client folder is also removed from the Backup folder.
The modified command is:
Code
rsync -arz --delete /home/Client /home/Backup
-a=Archive mode; copies all attributes
-r=Recursive; also synchronizes subfolders
-z=Compression; data is compressed depending on the amount and size of the data
--delete= Deletes data that no longer exists in the source but is still present in the destination
Step 3
To avoid running the command manually every time, you can add it to a cron job.
For example, to create a backup every day at 3 a.m.:
Open crontab -e:
Choose option 1 to use "nano" as the editor.
Choose option 2 to use "vim" as the editor.
After opening the file, for example with Nano, you can create and add a cron job.
You can create a cron job with this generator.
The command runs every day at 3 a.m. and creates a backup.
Step 4
In this example, the Client folder in /home is synchronized with the Backup folder on a remote server. The connection uses an SSH key so that the backup can run automatically.
Important: Rsync must also be installed on the remote server.
Code
apt install rsync
For example, you can use the following command to back up the data to the remote host (adjust as needed):
-a=Archive mode; copies all attributes
-r=Recursive; also synchronizes subfolders
-z=Compression; data is compressed depending on the amount and size of the data
-e=Specifies the remote shell to use (default: ssh), for example, to specify an SSH key or a different port
Specify the SSH key (path)("ssh -i /home/sshkey/keybackup")= ssh -i /[path to key]
Specify the directory to back up (/home/client/)= /[directory]
Remote host (root@123.123.123.123:)= User login name on the remote host and address: name@IP/domain
Destination directory on the remote host (:/home/Backup/Home-Server1/)= :/[path to destination directory]
After running the command, the folders/files were successfully synchronized/backed up to the remote directory.
If a file, etc. is deleted from the Client folder, it remains in the Backup folder on the remote host.
However, if the files should always be identical, you can modify the rsync command so that data no longer present in the Client folder is also removed from the Backup folder on the remote host.
-a=Archive mode; copies all attributes
-r=Recursive; also synchronizes subfolders
-z=Compression; data is compressed depending on the amount and size of the data
--delete= Deletes data that no longer exists in the source but is still present in the destination
-e=Specifies the remote shell to use (default: ssh), for example, to specify an SSH key or a different port
Specify the SSH key (path)("ssh -i /home/sshkey/keybackup")= ssh -i /[path to key]
Specify the directory to back up (/home/client/)= /[directory]
Remote host (root@123.123.123.123:)= User login name on the remote host and address: name@IP/domain
Destination directory on the remote host (:/home/Backup/Home-Server1/)= :/[path to destination directory]
Step 5
To avoid running the command manually every time, you can add it to a cron job.
For example, to create a backup every day at 3 a.m.:
Open crontab -e:
Choose option 1 to use "nano" as the editor.
Choose option 2 to use "vim" as the editor.
After opening the file, for example with Nano, you can create and add a cron job.
You can create a cron job with this generator.