Saturday, May 25, 2024
HomeTutorialsHow To Backup Ext2, Ext3, or Ext4 File Systems in Linux

How To Backup Ext2, Ext3, or Ext4 File Systems in Linux

In Linux, the file system is used in Ext4 format for storing the OS. Since, like Windows, Linux doesn’t use NTFS or other conventional file types, it might be difficult for newbies to backup the Linux file systems.

Now, the question might be, why do you need to back up the file system on Linux? Well, it can be answered for many different circumstances; you might need to backup your entire file system and restore it to another virtual or physical system, or you might need to preserve the entire system for some security reason.

No matter the situation, there is always a way to backup the entire or partial Linux file system.

How To Backup Linux File System

As the OS is mounted on the file system on Linux, you can not copy the system which is currently in use. To avoid this type of complex situation, you can use 3rd party tools that can copy the system even if it is in use.

The Dump tool has been used by many users to backup your Linux system. The design architecture of the Dump tool allows the users to backup the running Linux files system in another drive. In this post, we will see how to backup Ext2, Ext3, or Ext4 file systems in Linux.

Step 1: Install Dump Command in Linux

Installing the Dump tool to backup Linux files is easy and hassle-free. Many professional Linux users often use this tool to reserve their entire system data.

The Dump tool is available on the Linux repository, and you can install it through the conventional package installer commands.

To install the Dump tool on your system, run the following commands according to your distribution.

  • Install Dump on Debian/Ubuntu Linux
sudo apt-get install dump

install dumo on Linux

  • Get the Dump tool Red Hat and Fedora Linux
sudo yum install dump  
  • Install Dump on Arch system
sudo pacman -S dump 
  • Get Dump on SuSE Linux 
sudo zypper install dump  

Step 2: Get to Know the Dump Tool on Linux

Before you start using the Dump tool on Linux, please ensure you understand the syntaxes we will run to backup the Linux file system. The following arguments might help you write your dump command on the shell.

$ sudo dump options arguments filesystem

Backup Linux File system

The Dump tool can backup, record, restore, and partially backup files on Linux. The following two Dump commands will let you know whether or not the current Linux file system was ever backed up. 

$ dump -W
$ dump -Ww

To know more about the dump tool, you can see the manuals for creating the backup and restoring the backup files on Linux.

$ man dump
$ man restore

Step 3: Backup System Files on Linux

You can measure how many files you want to backup on the Linux system and set the destination through the Dump tool. It allows the users to backup Ext2, Ext3, or Ext4 files on the Linux file system.

For instance, if we want to back up the /boot file system on Linux, you can run the following Dump command on the terminal shell.

Here, the destination of the backup file is assigned as the /my_backups/boot.0. You can set your destination directory to backup the files. 

In the same way, you can also backup the root, home, etc., directories on your Linux file system. 

$ sudo dump -0f /my_backups/boot.0 /boot

my_backups boot

The above screenshot shows how the tool can store blocks through the command-line interface. This is because the original design of the Dump tool worked in a manner where the tool could backup files block-wise from the hard drive.

Despite backing up the file, you can back up the other directories like sda1, sda2, sda3, and other folders through the Dump tool. Please do not forget to set a valid destination folder to backup files on Linux through Dump.

$ sudo dump -0uf /backup/sda1.dump /dev/sda1
$ sudo dump -0uf /backup/sda2.dump /dev/sda2
$ sudo dump -0uf /backup/sda3.dump /dev/sda3

Step 4: Partial Backup of File Systems

The Dump tool has been very useful for backing up files on Linux. It also allows the users to backup files partially so that they can just backup those files that they want. However, run the following command below to do a partial backup on the Linux file system. 

Please note that here, partial backup means that you can take the backup of a sub-directory of an entire file system, not backing up a little, then quit.

$ sudo dump -0f /my_backups/configurations.dump /etc/default /etc/network 

partial backup Linux File system

Step 5: Show Backups in Linux File Systems

Since we have seen how to take full backup and partial backup on Linux, it’s high time we see how to see the files we had backed up. The following command will let us know the context of the Ext2 to Ext4 backup files. 

$ sudo restore -tf /my_backups/configurations.dump 

Step 6: Restoring the Linux File System Backups

Restoring the data that we took for backup refers to the process of putting the files in the same directory as they were so that the Linux system can function properly.

To restore the files on a Linux file system, we will need to know if we want to restore the entire directory or a partial restore. However, you may execute the command below to restore files.

$ sudo restore -xf /my_backups/configurations.dump 

If you face issues restoring the files, please check whether you’re a root user. You may use the chown commands or the chmod commands to get access for restoring. If you’re trying to restore a file already in the system, you might face errors in creating symbolic links. 

Final Words

Once you understand all the above-explained commands, you’re ready to back up your files. With the Dump tool, backing up the Linux file system is easier and less complex than expected. If you still need to do an extensive backup of your files, you can try booting the GParted system to take the full backup.

In the entire post, we have seen how to install the Dump tool on various distributions, backup, and restore the Linux file systems. 

Please share this post with your friends and the Linux community if you find it useful and informative. You can also write your opinions on this post in the comment section.

Mehedi Hasan
Mehedi Hasan
Mehedi Hasan is a passionate enthusiast for technology. He admires all things tech and loves to help others understand the fundamentals of Linux, servers, networking, and computer security in an understandable way without overwhelming beginners. His articles are carefully crafted with this goal in mind - making complex topics more accessible.


Please enter your comment!
Please enter your name here

You May Like It!

Trending Now