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!

Notes on Installing Fedora 27 on the Lenovo Yoga 920

I try to stay as close to a stock Fedora experience as possible, with a few minor changes. The reason for this is so I will not have much setup to do if I get a new system or experience a catastrophic failure. I choose my tools and environment carefully and as a result a complete install as listed below usually takes me under an hour.  A video of this install guide is available here: https://www.youtube.com/watch?v=73mfFSUtXJg

  1. Shrink the Windows NTFS partition while in Windows. I have a 512 GB SSD, I shrunk the NTFS partition down to 200 GB to give me 300GB for my Fedora setup.
  2. Create the bootable USB with the Fedora install. I use the Fedora USB installer tool in Fedora to create the drive. You can also download the USB Media Install tool by clicking the “Workstation” download link at fedoraproject.org. The tool will step you through the creation of bootable Fedora USB media.
  3. Turn off Intel Secure boot. This may have an impact on the installation of Fedora.
  4. Follow the steps to install Fedora as usual. The installer hasn’t really changed in the last five or so versions. Installing Fedora Linux: https://youtu.be/eTYOrIFABhU?t=4m22s
  5. Once the install is completed, you will need to create a blacklist file in /etc/modprobe.d with blacklist ideapad_laptop in order to get the WiFi card working. For a quick fix that doesn’t require a reboot, issue this command: sudo modprobe -r ideapad_laptop  This has been a problem with Yoga laptops for a while. The problem will be fixed with step 6.
  6. dnf update -y don’t skip this step or number 7. Fedora 27 is not stable from the stock iso image unless you do the updates.
  7. Reboot.
  8. hostnamectl set-hostname fedoraiscool Use this command to set your hostname to whatever you want. The command as used would set your host to fedoraiscool.
  9. dnf group install kde-desktop-environment My preference is KDE Plasma for the desktop. You can also just download the KDE spin of Fedora, but this is how I choose to do it. At times I will use the default Gnome 3.x desktop.
  10. Enable rpmfusion: sudo dnf install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm
  11. Install some software packages: sudo dnf install -y guvcview chromium rhythmbox kdenlive gimp tlp vlc VirtualBox audacity obs-studio handbrake  There are many more software packages to choose from, these are the ones I typically use in my daily workflow that are not already installed by default.
  12. Start the tlp battery saver service: sudo tlp start
  13. Enable tlp at startup: sudo systemctl enable tlp
  14. Disable Bitlocker so you can mount your Windows partition in Linux. Please note that my Yoga 920 was shipped with Bitlocker enabled on the C: drive. You may have to use Disk Management in Windows to turn off Bitlocker which can take a while.
  15. Mount your windows partition. Make a mount point for your windows partition: sudo mkdir /mnt/windows Then, sudo mount /dev/nvme0n1p3 /mnt/windows  It may vary as to which device it is. Use sudo fdisk -l to determine which partition you need to mount. Or lsblk or sudo fdisk -l | more to control output.
  16. Make GUI changes as desired. Some of the setting changes I make in KDE desktop are to set the mouse for two clicks (the default is one) change the minimize, maximize and close widgets, change the default screen lockout time, change power save settings, and change the desktop image.
  17. Optionally, install Steam if you would like access to your Linux based Steam games while in Fedora. In the CLI, simply type sudo install steam

Sources: