Don’t risk data loss. Back up your valuable data from the Linux command line. For this we will use the command
rsync and we even found some nice GUIs for it.
There are many ways to back up your files. We wanted to show you a reliable, flexible and reliable way to protect your data. We chose
rsync because of its respected algorithms that calculate the differences between files in the source directory and the target directory. Only the differences between the two versions of the file are transferred, not the entire file if this can be avoided.
When this efficiency is combined with its solid track record of doing file copies and directory synchronization since the mid-1990s,
rsync is an excellent candidate for creating backups from the Linux command line.
In addition, there are independent programs that act as an interface to
rsync . They provide a graphical user interface (GUI) for
rsync which some people may find easier to use.
The easier and faster it is to make a backup, the more likely you are to make it.
Using rsync with an external hard drive
To back up your data to an external hard drive, the hard drive must be mounted and available to you. If you can write to it, then
rsync . In this example, an external USB hard drive named SILVERXHD (for «Silver eXternal Hard Drive») is connected to a Linux computer. It was automatically mounted by the operating system.
You will need to know the path to the drive. In GNOME, open the Nautilus file browser and look for the drive name in the sidebar.
Hover your mouse over the name of the external drive and the tooltip will display the path to the drive.
In this example, the tooltip tells us that the file system mount point on the external drive is «/media/dave/SILVERXHD».
If your file browser doesn’t, navigate to your external drive and open a terminal window at that location. Use command
pwd to print the path to the terminal window.
Copy content from source directory
rsync To copy the contents of the directory to the backup destination, use the following command.
-r (recursive) forces
rsync copy all nested subdirectories and their contents. Note that there is a slash «/» at the end of the word «SILVERXHD», but it is wrapped to the next line in the screenshot.
rsync -r / home / dave / документы / / media / dave / SILVERXHD /
The file will be copied and you will be returned to the command line.
If we look at the external USB drive, we can see that the directories in the Documents directory have been copied to the external drive’s root directory.
Copying the source directory and its contents
If you wanted to copy the Documents directory and its contents to an external drive, remove the «/» at the end of «/home/dave/Documents» on the command line, like so:
rsync -r / home / dave / документы / медиа / dave / SILVERXHD /
To avoid confusion, I removed the two previously copied directories from the external drive before running this second command.
If we let the second copy complete and take another look at the external drive, we can see that the Documents directory has been copied. Its contents are in this directory. They are not in the root of the external drive.
Copying to a specific target directory
To copy to a specific directory on the target hard drive, add the directory name to the target path. Suppose we want to copy the contents of the «/home/dave/Documents» directory to the «backups» directory on an external drive.
We will do this with the following command.
rsync -r / home / dave / документы / / media / dave / SILVERXHD / backups /
Checking the external drive, we can see that a backup directory has been created and that directory contains the contents of the «/home/dave/Documents» directory.
Maintain file ownership and permissions
Use the parameter
-a (archive) to preserve file attributes such as modification dates, file ownership, permissions, etc. for copied files, symlinks, and special block files.
rsync -ra / home / dave / документы / / media / dave / SILVERXHD / backups /
Using detailed mode
-v (verbose) forces
rsync list files as they are copied.
rsync -rav / home / dave / Документы / / media / dave / SILVERXHD / backups /
A summary of the backup is displayed after the backup is completed.
- Sent : bytes transferred to the target.
- Received : bytes received at the host.
- Byte/sec : Effective transfer rate.
- Overall size : represents the size of the data that would be sent if you not used
rsync. At subsequent
rsyncit will only transfer file differences. This figure will represent data that not had to be transferred.
- Acceleration : This is the ratio between the amount of data that should have been sent and the total amount of data that is. If a
rsyncit is necessary to copy all the files in their entirety (for example, at the first start), the speedup will be 1.0. When
rsyncis used next time, it optimizes the transmission. It will only send the differences between files, not entire files. Files without changes will be ignored. The speedup will be the ratio between the small amount of data that needed to be transferred and the total size of the files.
Using the Progress Parameter
-P (progress) forces
rsync generate a small progress report after copying each file.