0% found this document useful (0 votes)
249 views4 pages

How To Use Rsync To Create A Backup On Ubuntu 20.04 - Serverspace

The document explains how to use rsync to create backups on Ubuntu 20.04. It describes installing rsync if not already present, then configuring the data source server by editing /etc/rsyncd.conf to specify the source path and credentials. Finally, backups are run by calling rsync and specifying the source and destination paths, with authentication via a password file. Regular backups can be automated by adding the rsync command to /etc/crontab.

Uploaded by

Martín Lehoczky
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
249 views4 pages

How To Use Rsync To Create A Backup On Ubuntu 20.04 - Serverspace

The document explains how to use rsync to create backups on Ubuntu 20.04. It describes installing rsync if not already present, then configuring the data source server by editing /etc/rsyncd.conf to specify the source path and credentials. Finally, backups are run by calling rsync and specifying the source and destination paths, with authentication via a password file. Regular backups can be automated by adding the rsync command to /etc/crontab.

Uploaded by

Martín Lehoczky
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

How to Use Rsync to Create a Backup on Ubunt... https://serverspace.us/support/help/use-rsync-to...

TUTORIALS INSTRUCTIONS HOW TO USE RSYNC TO CREATE A BACKUP ON UBUNTU 20.04

How to Use Rsync to Create a Backup on


Ubuntu 20.04

There are many ways to make a backup on Ubuntu. Recently, we looked at a powerful but
complex tool – Bakula. Today we will learn how to make a backup using rsync.

Step 1 – Installing rsync

Ubuntu 20.04 already contains the rsync package installed. To check this and find out the
version, use the command:

sudo rsync --version

If the package is not installed for some reason, use the command:

sudo apt install rsync

To launch rsync as a service in Ubuntu 20.04, create the /etc/rsyncd.conf file and copy
/lib/systemd/system/rsync.service to /etc/systemd/system/rsync.service.

sudo nano /etc/rsyncd.conf # save and close it


sudo cp /lib/systemd/system/rsync.service /etc/systemd/system
/rsync.service

Now restart the service.

1 de 4 14/10/20 20:33
How to Use Rsync to Create a Backup on Ubunt... https://serverspace.us/support/help/use-rsync-to...

sudo systemctl restart rsync

Step 2 – Configuring the data source server

First, add these lines to the rsync configuration file /etc/rsyncd.conf. Change the ‘path’
parameter to the path to the source files to back up. For ‘uid’ and ‘gid’, use the existing
username and group with read permissions in the backup source folders.

sudo nano /etc/rsyncd.conf


# Global configuration of the rsync service
pid file = /var/run/rsyncd.pid
# Username and group for working with backups
uid = backup-user
gid = backup-user
# Don't allow to modify the source files
read only = yes
# Data source information
[data]
path = /path/to/backup
list = yes
auth users = backup-user
secrets file = /etc/rsyncd.passwd

The data in the ‘auth users’ parameter and the /etc/rsyncd.passwd file is used for authorization
between rsync on different computers. Add a line there, like this:

sudo nano /etc/rsyncd.passwd


backup-user:test-pass

Change the permissions for the rsyncd.passwd file.

2 de 4 14/10/20 20:33
How to Use Rsync to Create a Backup on Ubunt... https://serverspace.us/support/help/use-rsync-to...

sudo chmod 0600 /etc/rsyncd.passwd

Restart the service to apply the changes.

sudo systemctl restart rsync

Step 3 – Running the backup

Create the /etc/rsyncd.passwd file on the receiving server where the backups will be stored.
Enter the same password as on the source computer, but without the user name, set 600
permissions for it.

sudo nano /etc/rsyncd.passwd


test-pass # Save and close file
sudo chmod 0600 /etc/rsyncd.passwd

To perform a backup run the command:

rsync -a --password-file=/etc/rsyncd.passwd backup-


user@source-server-ip::data /destination/path/$(date
+%Y-%m-%d)/

Replace source-server-ip with the IP address of the first server, and ‘/destination/path/’ with
the path for storing backups.

For regular backups, just add the task to the end of the /etc/crontab file.

3 de 4 14/10/20 20:33
How to Use Rsync to Create a Backup on Ubunt... https://serverspace.us/support/help/use-rsync-to...

4 de 4 14/10/20 20:33

You might also like