Could we help you? Please click the banners. We are young and desperately need the money
In the world of Linux system administration, ensuring data integrity and system availability is paramount. Our enhanced open-source backup script addresses these critical needs by offering a powerful combination of advanced features that set it apart from traditional backup methods. And it's all free! 😉
At the heart of this solution is the ability to create full partition backups of your Linux system while it's running, eliminating the need for disruptive reboots. This live backup capability ensures that your services remain available and productive, even during the backup process.
The latest version introduces intelligent multi-drive backup selection, automatically choosing the optimal backup destination from your configured local and network drives. This smart selection algorithm ensures balanced backup distribution and maximizes storage efficiency across your infrastructure.
Security is a top priority in our backup strategy. The script implements optional strong encryption for your backups, safeguarding your sensitive data from unauthorized access. This encryption, coupled with best practices for secure storage, provides a robust defense against data breaches and ensures the confidentiality of your backups.
To keep you informed about the status of your backups, we've integrated a comprehensive email monitoring system with automatic configuration validation. This feature provides real-time notifications about backup successes, failures, interruptions, and any potential issues that may require your attention. With this proactive monitoring, you can rest assured that your backup processes are functioning as expected and quickly address any problems that arise.
The script now features automatic versioning with timestamped backups and intelligent cleanup of old versions, ensuring you maintain optimal storage usage while retaining the necessary backup history. Each backup receives a unique timestamp, and the system automatically manages retention based on your configured preferences.
Furthermore, this script is capable of creating on-the-fly backups of LUKS (Linux Unified Key Setup) encrypted volumes, ensuring that even your most sensitive encrypted data can be backed up securely without compromising its protection.
One of the standout features of this backup tool is its ability to restore backups on volumes smaller than the original source volume. This flexibility allows for easier migration to smaller drives or partitions, making it an invaluable tool for system upgrades and storage management.
The enhanced version includes comprehensive signal handling and graceful interruption management, ensuring that incomplete backups are properly cleaned up and temporary mount points are automatically managed when the process is interrupted or terminated.
Best of all, this powerful backup solution is available as free, open-source software. This not only makes it accessible to all Linux users but also allows for community-driven improvements and customizations to meet specific backup needs.
Let's dive into the details of this robust, secure, and efficient Linux backup solution that keeps your systems protected without interrupting your operations.
For Linux system administrators and power users, finding a reliable and efficient full system backup solution can be challenging. Many seek a method to create complete system image backups while the system is running, avoiding the need for downtime or reboots. In this comprehensive guide, we'll explore our enhanced FSArchiver script that allows you to perform live full system backups on Linux with intelligent drive management and comprehensive automation.
Feature | This Script | dd | Clonezilla |
---|---|---|---|
Live Backup | Yes | Limited | No |
Intelligent Drive Selection | Yes | No | No |
Network Drive Support | Yes | No | Limited |
Automatic Versioning | Yes | No | No |
Compression | Yes (ZSTD) | No | Yes |
Encryption | Yes | No | Yes |
Email Notifications | Yes | No | No |
Signal Handling | Yes | No | Limited |
Selective Backup | Yes | No | Yes |
LUKS Volume Backup | Yes | Limited | Yes |
Restore to Smaller Volumes | Yes | No | Limited |
Visit our GitHub repository for the latest version of the script:
The script ensures it's run with root privileges, which are necessary for accessing all system files and partitions.
The script automatically selects the best available backup drive from your configured list of local and network drives, choosing the drive with the oldest newest backup to distribute backup load efficiently.
An enhanced configuration system supports both local drives (UUID-based) and network drives (SMB/CIFS, NFS), allowing flexible backup target management.
Each backup receives a unique timestamp (YYYYMMDD-HHMMSS format), and the script automatically manages old backup cleanup based on your configured retention policy.
Comprehensive signal handling ensures graceful shutdown, cleanup of incomplete backups, termination of running processes, and removal of temporary mount points when interrupted.
The script provides three types of email notifications:
Automatic validation of SSMTP configuration ensures email notifications will work properly before starting the backup process.
Built-in extensive exclusion list covering cache directories, temporary files, log files, development directories, virtual filesystems, and container data.
The script implements multiple validation layers:
Native support for network storage solutions including SMB/CIFS shares and NFS mounts with automatic connectivity and permission validation.
To enable email notifications, you'll need to install and configure SSMTP. The script now automatically validates your SSMTP configuration:
sudo apt install ssmtp
sudo nano /etc/ssmtp/ssmtp.conf
Add or modify the following lines:
mailhub=your-mailserver.tld:587
hostname=your-desired-hostname
FromLineOverride=YES
UseSTARTTLS=YES
UseTLS=NO
AuthUser=your-username@your-domain.tld
AuthPass=your-email-account-password
Note: If you're using SSL Port 465, you may need to use UseTLS=YES
instead of UseSTARTTLS=YES
. The script will automatically validate your configuration and provide specific error messages if settings are missing or incorrect.
Use this code to quickly and easily test your SSMTP configuration on the console. If it does not work, check out your syslog.
Copy/paste the following code on your terminal, change the MAIL_FROM and MAIL_TO e-mail addresses and execute it. SSMTP should send the e-mail:
MAIL_FROM="sender@example.com" MAIL_TO="recipient@example.com" && echo -e "From: $MAIL_FROM\nTo: $MAIL_TO\nSubject: SSMTP Test Email\n\nThis is a test email sent using ssmtp." | ssmtp -t
If you did not receive any e-mail, check the syslog. On most system it's either:
tail -F /var/log/syslog
or
tail -F /var/log/messages
git clone https://github.com/lexo-ch/fsarchiver-encrypted-full-system-backup-script-with-email-monitoring.git
cd fsarchiver-encrypted-full-system-backup-script-with-email-monitoring
Option 2 - Manual Creation:
Copy the entire script into a new file, e.g.: fsarchiver_backup.sh
chmod +x fsarchiver_backup.sh
(or chmod +x backup_script.sh
if using GitHub version)sudo nano /root/backup-password.txt
and enter your desired encryption password (optional).sudo ./fsarchiver_backup.sh
The enhanced script supports multiple backup drives with intelligent selection:
BACKUP_DRIVE_UUIDS=(
"12345678-1234-1234-1234-123456789abc" # Your USB drive UUID
"87654321-4321-4321-4321-cba987654321" # Your external drive UUID
)
BACKUP_DRIVE_UUIDS=(
"//your-server.local/backup" # SMB/CIFS share
"192.168.1.100:/mnt/backup" # NFS mount
)
BACKUP_DRIVE_UUIDS=(
"12345678-1234-1234-1234-123456789abc" # Local USB drive
"//your-server.local/backup" # SMB network drive
"192.168.1.100:/mnt/backup" # NFS network drive
)
The script automatically detects drive types and selects the optimal drive based on backup age analysis.
To schedule regular backups, you can use cron jobs. Here's how to set up a weekly backup:
sudo crontab -e
0 2 * * 0 /path/to/fsarchiver_backup.sh
This backup script relies on several system utilities to function correctly. Key dependencies include:
The script now includes comprehensive dependency checking and will provide specific installation instructions if any required utilities are missing.
If you run the script and see an error message about findmnt not being found, you can install it using:
sudo apt update
sudo apt install util-linux
Our enhanced backup script continues to work seamlessly with LUKS (Linux Unified Key Setup) encrypted volumes. The script can back up LUKS volumes without requiring any special configuration, as long as the volumes are properly mounted:
BACKUP_PARAMETERS
associative array for your LUKS volume:
BACKUP_PARAMETERS["LUKS_Volume"]="backup-luks:/media/username/VolumeName"
The script will automatically create timestamped backup files and manage versioning.
The script will automatically determine the correct device path for your LUKS volume and create secure backups while maintaining encryption integrity.
The script now provides comprehensive error reporting and troubleshooting:
The script uses configurable ZSTD compression with intelligent defaults:
ZSTD_COMPRESSION_VALUE=5 # Default balanced setting
Adjust the ZSTD_COMPRESSION_VALUE
in the script configuration to balance between backup size and speed for your specific needs.
To integrate with cloud storage, you can use tools like rclone. The script's timestamped backups make cloud synchronization straightforward:
# Add to end of script or separate sync script
rclone copy /path/to/backup-drive remote:backup-folder --include "*.fsa"
-o
: Overwrite the output file if it already exists-v
: Verbose mode, shows detailed progress-A
: Allow to save a filesystem which is mounted in read-write-j$(nproc)
: Use multiple threads for compression (number of CPU cores)-Z[level]
: Set ZSTD compression level (0-22, configurable)-c
: Create an encrypted archive (optional)--exclude
: Exclude paths from backup (extensive built-in list)The script creates timestamped backups and automatically manages versions:
backup-root-20250626-143022.fsa
backup-root-20250625-143015.fsa
backup-efi-20250626-143025.fsa
The script analyzes backup ages across all configured drives and selects the drive that most needs updating, ensuring balanced usage and optimal backup freshness.
Built-in exclusion patterns cover:
To restore a backup, use the following command:
sudo fsarchiver restfs /path/to/backup-root-20250626-143022.fsa id=0,dest=/dev/sdXY
Replace the backup file path with your specific timestamped backup and /dev/sdXY
with the target partition.
For restoring the data, the fsarchiver team recommends using this rescue system:
https://www.system-rescue.org/
Important: This script is provided as-is, without any warranty or guarantee. Users should understand that they are using this script at their own risk. LEXO does not take any responsibilities or liabilities for any data loss, system damage, or any other issues that may arise from the use of this script. It is strongly recommended to thoroughly test the script in a non-production environment before using it on critical systems. Always ensure you have multiple backups of your important data using various methods.
This enhanced FSArchiver-based backup script offers a powerful, intelligent, and flexible solution for Linux users seeking a reliable way to create full system backups without rebooting. The new features including intelligent drive selection, automatic versioning, comprehensive signal handling, and network drive support make it suitable for both single-machine and enterprise environments.
By leveraging open-source tools and advanced automation features, you can ensure your critical data is protected while maintaining system uptime and operational efficiency. The script's ability to handle multiple drives, network storage, and complex backup scenarios makes it an ideal foundation for comprehensive backup strategies.
Remember to regularly test your backups and restore processes to ensure the integrity of your data and the effectiveness of your backup solution. With proper implementation and maintenance, this enhanced script can significantly improve your Linux system's data protection capabilities while providing the flexibility and reliability needed for modern IT environments.
By following this guide and utilizing the enhanced script, you can implement a robust, automated, secure, and intelligent backup solution for your Linux systems. The script's advanced features ensure reliable data protection while minimizing administrative overhead and maximizing backup efficiency across your infrastructure.