5 Backup Tools Built-in to Linux

Want to see a more detailed video on this article? Click here!

There are plenty of backup tools available in Linux, but I prefer applications that are already built-in to the distro you are using.  Let’s take a look at 2 GUI tools you can use and 3 CLI tools.  This article is written mainly for Fedora, as that’s the distribution I use. All the solutions should be available on any distro as well as FreeBSD.  The CLI tools are also available on MacOS. Let’s get started!

1. The Gnome Disk Utility

The first tool is a GUI tool that is a part of the Gnome desktop. If you don’t have Gnome installed, you can still install the “Disks” graphical tool:

sudo dnf install gnome-disk-utility

I recommend exporting your image file to an external drive. The drive will need to be bigger than the partition you are backing up. Keep in mind the image size will be the same size as the partition you are backing up.

For more information, click here.

2. Dolphin, Nautilus, or Other File Management Tool

There are several file management tools for any distro and desktop interface you are using in Linux. The 2 most popular in Linux are Dolphin and Nautilus. If you ever used File Manager in Windows or Finder in MacOS, this should be easy for you. Simply select the file or folder you want to backup, and drag it to external media (usually a USB drive or thumb drive).

The nice thing about this backup is you can select specific files and/or folders. You don’t need to backup the entire partition, which saves time and disk space on the target device you are backing up to.

I suggest backing up at least your home directory. My user name is mark, so the path to my home directory is /home/mark. In the example image below, I’m backing up my Documents folder, located at /home/mark/Documents.

3. The dd CLI Tool

Similar to the Disks GUI tool, dd will make a backup image of a partition or disk. The difference is it’s a command line tool. If you don’t know the disk or partition you want to backup, you can use fdisk first:

fdisk -l

The drive we are going to backup is /dev/sdf. It helps if you know the device size so it’s easier to identify in fdisk. You can also use the Disk Utility in Gnome or the Partition Manager in KDE Desktop. Once we know the drive to backup, we type in the dd command:

dd if=/dev/sdf of=/mnt/4tb/2gb_sd.img

We can also backup just a partition on a particular drive or device. For example, if we want to backup partition 1 on sdf, we’d use this command:

dd if=/dev/sdf1 of=/mnt/4tb/2gb_sd_part1.img

Note that we used sdf1, just as we saw in the fdisk output earlier. The image was renamed 2gb_sd_part1.img so we know what exactly we put in the backup.

We can also backup from a disk to a disk, and avoid having to create an image file. Note that the target drive must be equal to or larger than the source drive/partition:

dd if=/dev/sda of=/dev/sdc conv=noerror,sync

Note that we are sending the /dev/sda source to the /dev/sdc drive. You have to make sure you’ve selected the right target device/drive or you will erase a drive you need!!

For more information, click here.

4. The tar command

an acronym for “Tape Archive,” tar was originally used to backup files, directories or disks to a tape drive, which was assigned a device, such as /dev/st0. In this case, we’re going to use tar to backup our documents directory located in the home folder of user mark:

tar -zcvpf /mnt/4tb/Backups/backup-mark-docs.tar.gz ~/Documents

The backup file “backup-mark-docs.tar.gz” will be written to my 4 TB drive in the /Backups directory. You may be wondering what the switches are for:

z : Compress the backup file with ‘gzip’ to make it small size.

c : Create a new backup archive.

v : verbosely list files which are processed.

p : Preserves the permissions of the files put in the archive for later restoration.

f : use archive file or device ARCHIVE.

If you are restoring your documents directory back to the user’s documents directory, the command would look something like this:

sudo tar -xvpzf /path/to/backup.tar.gz /restore/location -C --numeric-owner

Note the -C in the command. This is important because it ensures the tar file gets restored to the right place. Our actual command to restore documents to the user mark would look like this:

tar -xvpzf /mnt/4tb/Backups/backup-mark-docs.tar.gz ~/Documents -C --numeric-owner

If we are using tar to restore files or directories, it would be best for a complete restore, in the event all user data was lost.

For more cool ways to use tar, check out this link.

5. The rsync command

Rsync is one of the easiest and quickest backup tools to use. It can backup from a local drive to a local drive, networked server, or even a remote server. Perhaps the best feature of rsync is that it will do an incremental backup of your source after the first time. This means any new files or changed files will get backed only, greatly speeding up the process!

Let’s use rsync to backup the documents directory again:

rsync -avzh --progress ~/Documents /mnt/4tb/Backups/docs-rsync

Rsync will automatically create the target directory if it doesn’t already exist. In the above example, the directory docs-rsync will be created on the 4 TB drive. Let’s see what happens the second time you run rsync, after updating a single file:

After updating one file, the speedup was 89,807 times faster than the first time we ran rsync. You can expect the first time to take a bit of time, but thereafter, it will be much faster.

I recommend using a larger USB thumb drive or an external USB drive so you can remove the backup if necessary and store it somewhere else. Restoring the data is a breeze, you can use a file manager tool like Dolphin or Nautilus. You can also “restore” a single document or file by simply copying it back from the backup location to the source location.

rsync can be automated in many different ways, such as by using a script to run it, or even having cron run the script for you on a regular basis. Using cron for automated backups it beyond the scope of this article, but you can click here for more information! We’ll be doing a more in depth article on rsync and cron in the future.

I hope this article was useful, and gives you a few ideas on how you can do a quick backup and save yourself the headache of losing data. Using Linux and doing backups is not nearly as daunting as it seems, once you get used to it. Don’t be afraid to give it a try!

Welcome to my Universe!

276 tech videos in 2 years. Not too bad!

It’s been 2 years this April 2018 since I created the FastGadgets YouTube channel.  I really did it on a whim, not sure what it might become.  Of course, I always had hopes it would become something huge, a full time endeavor I could use as my primary income.  It hasn’t quite become that yet, but it’s getting closer.

Since that fateful day in April of 2016, I created 276 tech related videos (as of 18th January, 2018).  That’s an average of 13 videos a month!  It seems trivial, but the time, effort, and love I’ve put into each video has been a joy.  I would say the best part is the viewers, who’ve really made the journey so much fun.

I’d been planning on doing something with the fastgadgets.info domain I purchased years back, but never got around to it.  It’s been parked on my YouTube channel, so anyone who went to fastgadgets.info would simply be forwarded to YouTube.  The thing is, I began to realize all these videos and tutorials I do really deserve to have some kind of corresponding blog post.

Many of them are “how to” Linux videos, and I really have been meaning to create a text based repository of Linux knowledge that I’ve learned over the years.  Also, I realized I do so much more than just Linux.  I’ve got quite a few videos on Mac related content, Windows, networking and some security as well.

The plan here on out is to develop content here for you,  the aspiring IT person, as well as the everyday user who just needs a quick bit of information to get things going.  I hope you find this site useful, and look forward to offering up my knowledge in the hopes it might help someone out, even if just a little bit.

Thanks for visiting!

Mark