Simple Linux Backups with Rsync command

Introduction

Having a comprehensive data protection policy in place is now a fundamental practice to help ensure your data manages to weather all the storms that can be thrown at it. Saying that it should be done is the easy part, actually doing it gets more complex, and laborious, depending on the policy in place and what standards and laws the organization needs to adhere to. Fortunately, for Linux users there a tool exists that makes backing up data a breeze, and it can all be done from the command line.

Recommended Read: Backup Linux data to Amazon S3 with CloudBerry Backup

Also Read: Cloud Backup Roundup: Azure vs AWS vs GCP

Rsync to the Rescue

Any news related to Linux often is an opinion piece as to how great the OS is or what distro hoppers are saying in the best new Linux distribution. Fortunately, there is a treasure chest of how-to guides but finding the right one can be difficult. To keep this guide to the point it will focus only on how to create a backup using rsync. There exist multiple ways to backup systems, including third-party products with easy to use interfaces, but rsync is readily available to any Linux user who enjoys tapping into the command line.

Rsync operates by transferring and synchronizing files between a machine and an external drive. It is not limited to external drives and the transferring and synchronizing of files can be done across a network. This is incredibly handy, but rsync also allows users to compare modification dates and file sizes, making sure when backups are done and no time is wasted backing up files that have already been done.

Rsync’s Simplest Use Case

Utilizing rsync’s most basic features allows the user to backup, modify, and delete files via the use of a remote server. The question remains, but how? Using Rsync’s basic syntax that’s how.

This will look like :

$ rsync SRC DEST

SRC being the source and DEST the destination. So, when uploading to your chosen backup device or folder the source will be what you want to backup and the destination is where you want to send the backup. If using a remote server, the destination will be a folder on the remote server. Rsync’s behavior can be further customized using the “-a” command. This will tell rsync to keep everything and copy all files in the selected directory. This is done recursively by the tool. In the wild the command will look something like this, notice the “-a” after rsync:

$ rsync -a local_directory someone@remote_server:/path/to/backup_directory

To delete extra files that have been generated over time in the backup folder rsync uses the “ — delete” command. The command will tell the tool to delete files that are in the destination directory and not present in the source directory. The command should look something like this:

$ rsync -a — delete local_directory someone@remote_server:/path/to/backup_directory

That covers the basics of the backup process, but what about retrieval? By using the rsync and “-a” command, you just need to swap the source and destination folders to upload the backup to the required local machine. In practice it will look like this:

$ rsync -a username@remote_server:/path/to/backup_directory local_directory

Conclusion

This was just a basic overview of Linux Backups with Rsync and how it is a great tool for doing backups on a Linux system. By default the tool uses a remote shell, similar to SSH, to transport the files from one location to another, this can be changed but will be covered in a separate article covering rsync in greater detail.

We are giving you exclusive deals to try Linux Servers for free with 100$ credit, check these links to claim your 100$,

DigitalOcean — 100$ free credit & Linode — 100$ free credit

Check some Exclusive Deals, HERE.

Also, check out DevOps Book You should read section.

--

--

--

http://linuxtechlab.com is a beginner friendly website where you can learn Linux Tips & tricks,Scripting, also has lots of tutorials aimed at making Linux easy.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Why DevOps culture matters working with the Power Platform?

Protecting your NestJS API with Keycloak

Checkout git repository via SSH — Ansible module git

Understand Recursion and Memoization in Python Programming

🔰Ansible playbook that will retrieve new Container IP and dynamically update the inventory and…

Schedule a Cron Job task in Linux — Ansible module cron

From ECS to Kubernetes

Ruby & Rails — some thirst satisfiers!

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
LinuxTechLab

LinuxTechLab

http://linuxtechlab.com is a beginner friendly website where you can learn Linux Tips & tricks,Scripting, also has lots of tutorials aimed at making Linux easy.

More from Medium

Beginner’s Guide to Linux Command Line

The Linux Commands Series: Part III

Linux commands

Copying files to and from remote server using ssh

type in terminal: man scp