Something You Didn’t Know About Backing Up a Linux Server
The open-source Linux operating system is popular for cloud environments, allowing users to fully leverage cloud advantages.
Linux servers prioritize user security, flexibility, and stability, making them a preferred choice for developers needing site backups.
Backup solutions are crucial for preserving data for a vast range of users, especially system administrators and those handling corporate data. Digital preservation is a key responsibility.
While beneficial, backing up a Linux server requires some learning. Several useful programs are available. Here’s how to create backups using ‘Tar’ and ‘Bera.’
Tar Method as a Backup Tool
This example uses Ubuntu, a popular Linux-based server operating system.
Creating Backup with Tar Command
Type:
sudo tar –cvpzf backup.tar.gz –exclude=/home/server/backup.tar.gz –one-file-system
This command initiates the backup process, archiving all data files on the server in g-zipped format. The backup file can be named as desired; in this case, it’s backup.tar. The -exclude flag prevents the backup from including itself in future iterations.
The ‘Tar’ command simplifies file and folder setup by automatically creating a directory for the server.
After entering the command, press Enter.
The file archiving will begin. When working with the root channel, it typically returns to previously installed directories.
Important: Ensure the server is not undergoing maintenance during the backup process to avoid delays.
Extraction with Tar Command
Type:
sudo tar -xvpzf /home/server/backup.tar.gz -C / –numeric-owner
Press Enter.
This command extracts the files, overwriting any previous backups or installed files (assuming a functional system).
If the system is completely reinstalled, the data will be restored to its original state.
The -f flag specifies the backup file. For optimal usability, restore the backup to the same folder if the backup location is the home server and the backup is a root backup.
After extraction, restart the PC to restore the system to its backed-up state.
Important: While storing backups on USB devices is possible, it’s generally not recommended due to file size hindering backup speed. Keeping backups at the root of the system or server is preferred.
Bera Method as a Backup Tool
Bera Backup offers comprehensive Linux server backups with a wider range of file extension support than ‘Tar’.
This command streamlines server migration in a shorter time, offering enhanced simplicity and convenience relative to the ‘Tar’ method.
The tool`s strength includes speed and simplicity, enabling complete server migration in minutes.
Bera simplifies the inclusion of folders and tabs during backups, with periodic notifications. Built on RSync, ‘Bera’ offers an additional level of security, a key difference from ‘Tar’.
Main properties of Bera Backup
File Backups are used for important files to include in your backup copy.
System Configurations include files like crontabs, users, and iptables, as well as all installed packages.
Creating a Backup
Type:
./bera-backup.sh _path_config_backup
Press Enter. Bera will then begin the backup process.
Important: It is strongly recommended to enable root permissions beforehand to avoid potential permission issues that can occur during or after backup & restore.
The command to Restore Backup
Type:
./bera-restore.sh _path_config_restore
Press Enter.
Remember the chosen path until the backup begins, as the ‘_path’ will retrieve the reserve copy from that location.
When setting up a backup, you will have these configurable options available for Bera:
Options
Overview
backupOrigin
Specifies ‘local’ if the server is where the backup is stored. Otherwise specifies ‘shh’, for other servers.
backupLocalDir
The local directory containing the backup copy (or the directory where it’s uploaded via SSH).
backupRemoteUser
SSH connection user (the server being backed up).
backupremoteserver
The SSH remote server hosting the backup.
backupRemotePort
The SSH server port.
backupRemoteDir
The remote directory where the backup is located.
Conclusion
Backups are crucial to ensure your content is safe and secure.
A backup ensures continuous access for visitors, even if your site experiences problems.
While the process may seem complex initially, you have a variety of methods to choose from. Don’t limit yourself to these methods—explore other tools like ‘Bacula’ and ‘Rsync Commands.’
We also advise carefully choosing a reliable hosting provider, avoiding cheap hosting traps.
Backups are not difficult if you take care during path and configuration selection. With care, the task can be easy.
Blog