srero2 ‘Backing Up With Reyne. Backup Your Fle Efficiently Using. | by Viekle Li |The Startup | Medium
Backing Up With Rsync
Backup Your Files Efficiently Using Just The Command Line
Vickie ti (Fatew )
Apr 23, 2020: 4 minread *
Photo by Markus Spiske on Unsplash
Is it time for a backup? Having a backup for your files is important if you do any work
on the computer. And if you are a system admin or a security professional, you might
even be legally required to backup company files regularly.
But unfortunately, creating backups can be a slow and laborious task. Today, we will
talk about a tool that will make that process easier: Rsync!
htpsmedium.comJswthvbacking-up-wih-rsyne 91529520638 48‘319/2021 Backing Up With Rsync. Backup Your Files Efficiently Using... | by Vickie Li| The Startup | Medium
Rsync is a Linux tool used for backup and file recovery. It transfers and synchronizes
files between a machine and an external hard drive, or across a network. Rsyne makes
the process more efficient by comparing the modification dates and sizes of files, and
only backing up when needed.
Uploading And Downloading Files Using Rsync
First, let’s go into the basics. How can you create a backup on a remote server using
Rsyne? How can you update the backup files? And how can you delete them?
This is the simplest usage of Rsyne:
Where SRCis the source directory of your files, and DEST is the destination that you
want to copy to, When you are uploading to a remote server, SRC would be a folder on
your local machine, and DEST would be a folder on the remote server.
Of course, we can also customize Rsyne’s behavior with options. One of the most
useful options is “-a”, which tells Rsync to preserve everything and copy all files in the
directory recursively. So to upload a folder to your backup server:
:/path/to/backup_directory
On the other hand, sometimes you might want to delete extra files in your backup
server. The ” — delete” option tells Rsyne to delete files in the DEST directory that is
not also present in the SRC directory.
delete loc
rname@remote_serve:
rsyi
directory
path/to/backup_directory
Congrats! You have now created a backup of your files. When the time comes, how can
you download the backups to your local machine?
htpsmedium.comJswthvbacking-up-wih-rsyne 91529520638 28sit Backing Up Wh Reyne. Backip Your Fes Econ Using. [by |The tap | Medium
You can simply reverse the SRC and DEST locations, and files will be downloaded
from the remote server instead.
rsync ~a us
local_dir
ame@remote_server:/path/to/backup_directory
y
Dry Runs
Sometimes, it is nice to be able to preview the changes that will happen before
finalizing a change in your directorie:
this is where Rsyne’s dry run feature becomes
useful. The “— dry-run”, or “-n” option tells Rsync to not execute any file transfers,
but show details of the file transfer that would happen instead.
rsync ~av --dry-run local_directory
username@remote_server:/path/to/backup_directory
The “-v’ option can be used if you want to see the verbose output. You can even
specify a log file to store the results if you want:
syne -av --dry-run local_directory
rname@remote_server: /path/to/backup_directory --log-
path/to/log_file
Using The Rsync Protocol
In all of the above examples, Rsync will use a remote shell like SSH as the transport
mechanism, Alternatively, you can connect to a remote Rsyne daemon directly by
specifying the Rsyne protocol for the remote path.
yne: //username@remote server: /module_name/file to download
local_directory
Rsync Server Configuration
htpsmedium.comJswthvbacking-up-wih-rsyne 91529520638 38‘319/2021 Backing Up With Rsync. Backup Your Files Efficiently Using... | by Vickie Li| The Startup | Medium
Finally, you can also launch a Rsyne daemon on your local machine. You might want
to do this if you want others to be able to access your files or be able to upload files
into your backup directory.
The Rsyne daemon’s configuration file is located at “/etc/rsyned.conf”. If it is not
already present on your computer, you'll need to create and edit it. Here's what a basic
configuration file looks like:
uid = root
gid = root
use chroot = yes
log file = path to daemon lock file
pid file th to process id file
hosts allow = * #all hosts can connect
#module options
modulei] #module name
comment = description for this module
path = /vickie/public_rsync #file path associated w
read only = yes #directory is read only, users canno
h this module
upload
After you're done specifying the configuration, you can launch the daemon by
running:
syne --daemon
Now the daemon is launched and Rsync is ready to accept connections! Anyone can
now connect to your Rsyne daemon by using the Rsyne protocol. This command will
download the file “file.txt” from your public Rsyne directory located at
“/vickie/public_rsync”.
rsync -a rsyne://username@your_server:/modulel/file.txt
ocal directory
Conclusion
htpsmedium.comJswthvbacking-up-wih-rsyne 91529520638 48sit Backing Up Wh Reyne. Backip Your Fes Econ Using. [by |The Stap | Medium
Rsync is a useful utility that streamlines the backup process. Today, we looked at how
to upload and download files through Rsyne, and how to create a local Rsyne server by
launching the daemon. Good luck.
Thanks for reading!
htpsmedium.comJswthvbacking-up-wih-rsyne 91529520638 58