Creating a Backup
Step 1: Using Tar for File Backup
1.1. Create a Backup Directory
Create a directory to store your backups:
sudo mkdir /backups
1.2. Perform a File Backup
To back up specific files or directories, use
sudo tar -cvpzf /backups/backup_file.tar.gz /path/to/directory_or_file
/path/to/directory_or_file with the actual path of the directory or file you want to back up.
Step 2: Using Rsync for Incremental Backups
2.1. Install Rsync (if not already installed)
sudo dnf install rsync
2.2. Perform an Incremental Backup
Rsync is useful for incremental backups. To sync and update the backup directory, use:
sudo rsync -av --delete /source/directory /destination/directory
Restoring from a Backup
Step 1: Restoring Files using Tar
1.1. Extract Backup Files
To restore files from a
sudo tar -xvpzf /backups/backup_file.tar.gz -C /path/to/restore
/backups/backup_file.tar.gz with the actual backup file and
/path/to/restore with the directory path to restore files.
Step 2: Restoring Files using Rsync
2.1. Sync Backup Files
To restore files using Rsync:
sudo rsync -av /backup/directory/ /destination/directory/
/backup/directory/ with the path of the backup directory and
/destination/directory/ with the path to restore.
- Regular Backup Schedule: Create a regular backup schedule to ensure up-to-date copies of your essential data.
- Automation: Utilize cron jobs or systemd timers to automate backup tasks.
- Verify Backups: Periodically verify your backups to ensure they are viable for restoration.
Creating and restoring backups on a Linux CentOS 8 server involves using tools like
tar for file backups and
rsync for incremental backups. It’s crucial to regularly create and verify backups to safeguard your data against potential loss or corruption.
By following this tutorial, you can efficiently create and restore backups on your CentOS 8 server, ensuring the safety and security of your important files and directories.
This tutorial covers the basic steps for creating and restoring backups on a Linux CentOS 8 server using
rsync. Adjust paths and commands as per your specific directory structures and backup needs.