Backup and Restore Data on Linux
In this article, we will explain how to back up and restore data on Linux systems using different tools like tar, rsync, dd, and cloud services such as Google Drive and Amazon S3. The guide covers both the backup and restore procedures for each tool.
One of the most commonly used tools for backing up files and directories in Linux is the tar command. It allows you to easily compress files and store them in an archive.
- Open Terminal
- To backup a specific folder (e.g., /home/user/data), use the following command:
Explanation:
- -c: Create a new archive.
- -v: Show detailed operations.
- -p: Preserve file permissions.
- -z: Compress using gzip.
- -f: Specify the archive file name.
To restore data from a .tar.gz archive file, use the following command:
- Open Terminal
- To restore data from a backup file to a specific directory, run the following command:
Explanation:
- -x: Extract files from the archive.
- -v: Show extraction details.
- -p: Preserve permissions.
- -z: Decompress with gzip.
- -C: Specify the destination directory for extraction.
rsync is another useful tool for backups, allowing you to synchronize data between directories, or even between servers.
- Open Terminal
- To backup data from a specific folder, run the following command:
Explanation:
- -a: Archive mode, preserves file attributes like permissions and timestamps.
- -v: Show detailed progress.
- -z: Compress data for faster transfer.
To backup from a remote server, use:

To restore data from a backup made with rsync, use the same command structure.
- Open Terminal
- To restore data from a backup directory, run:
To restore data from a remote server:
The dd tool is used for making complete backups of disks or partitions (for example, for backing up an operating system or a specific partition).
- Open Terminal
- To create a backup of a disk, use:
Explanation:
- if: Input file (the source disk or partition).
- of: Output file (backup destination).
- bs: Block size (in this case, 64K).
To restore data from a disk or partition backup created with dd, use the following command:
- Open Terminal
- To restore data to the target disk, run:
If you use cloud services like Google Drive or Amazon S3 for storing backups, the rclone tool allows you to back up and restore data to/from these services.
- Open Terminal
- To back up data to a cloud service, use:
- Open Terminal
- To restore data from the cloud service, use: