We'll now look at how to back up files in Linux,
there are many utilities out there and sophisticated tools for doing backups.
However, covering those is not the goal of this chapter,
we will focus on doing a backup in the most basic way,
copying files from one system to
another system that's designated backup location.
Our goal here is to understand the native Linux tools that can do that.
A popular tool to back up data is RSYNC.
Its name originates from remote synchronization
slash thumb slash directory on server.
One synchronized with slash thumb slash other directory on
server two by copying data through a network connection.
Now, the remote server must have an SSH daemon running on it.
Now, the general syntax looks like this
dash A is the archive option to
make sure that rsync also synchronizes subdirectories,
file permissions, modification times and so on.
For example,
to sync the local pictures directory to the remote pictures directory,
we could use something like this.
Now here, Aaron is the username 9.9 0.9 0.9 is the IP address of the server.
And the last part is the destination directory on that remote server
and make sure to always have a front slash at the end of your directory names.
Now, the cool thing about this tool when you run the command, next time,
rsync will only copy data that's been changed,
skipping old data that's still identical at both locations.
Which means that future backups will be optimized and
take less time to complete than the previous command.
Your local directory is the source which will get recreated at the destination.
But if you reverse these,
then the source will be the remote directory and
it will get recreated in your local directory.
It's also worth noting that you can rsync two local
directories as well instead of one local and one remote.
If instead of backing up files and directories,
you want to back up an entire disk or partition,
you can use the DD utility.
This takes sort of a picture of all the data on the disk or partition.
It's an exact bit by bit copy, which is why it's also called imaging.
Before saving a disk or partition image, you should unmount
that disk or partition to make sure that no data is being changed while you back it up.
Now, here's an example of AD D command
and status equals progress tells DD to show us the progress that it's making.
Now, if later you want to restore a disk image from a file back to disk,
you just reverse the if and of options.
Now as a note, you don't want to run this command on a virtual machine.
It will overwrite your virtual disk.