Repository: https://github.com/andreas-schwab-swx/dd_image
If you’re looking for a simple yet powerful solution for full disk image backups on Linux, the dd_image
script offers a versatile tool: it creates complete disk images, compresses them on-the-fly, and transfers them automatically via SSHFS to a remote server – with logging, retention logic, and optional notifications.
Features at a Glance
- Full disk backups using
dd
- On-the-fly compression with
xz
- Remote storage via
sshfs
- Automatic cleanup of old backups
- Progress monitoring and detailed logging
- Prevents concurrent runs using a lock file
- Optional email notifications on success or failure
- Optional zero-fill for better compression
Requirements
- Root access to a Linux system
- Installed tools:
sshfs
,xz-utils
,mailutils
(optional) - SSH access with key authentication to the backup server
- Sufficient storage space on the remote backup target
Installation and Configuration
Clone the repository and configure the script:
git clone https://github.com/andreas-schwab-swx/dd_image.git
cd dd_image
cp config.example.sh config.sh
nano config.sh
In the config.sh
file, you configure SSH access, the backup destination, the disk device (/dev/sda
, /dev/nvme0n1
, etc.), retention period, logging options, and email addresses.
Install the script:
chmod +x deploy-script.sh
sudo ./deploy-script.sh
The script is installed to /usr/local/sbin/dd_image.sh
, logs are saved in /var/log/dd_image/
, and configuration files are located in /etc/dd_image/
.
Run Backup Manually or via Cron
Run manually:
sudo /usr/local/sbin/dd_image.sh
Weekly cron job (e.g., Sunday at 2:00 AM):
sudo crontab -e
0 2 * * 0 /usr/local/sbin/dd_image.sh
Optional GitHub Actions Integration
For automated updates via CI/CD, you can use the included GitHub Actions workflow file (.github/workflows/deploy.yml
). SSH access to the server and defined secrets in your repository (HOST, USERNAME, SSH_KEY) are required.
Performance Tips
- Block size:
bs=32M
(recommended for systems with 8 GB+ RAM) xz
threads:-T2
(for systems with 4 vCPUs)- Compression:
-3
(default),-5
for better compression - Memory limit:
xz
is limited to 4 GiB to prevent RAM overload
Conclusion
The dd_image
script is ideal for anyone looking to create full system backups without relying on complex tools or graphical interfaces. Its combination of live compression, remote storage, and optional automation provides a solid foundation for any Linux backup strategy.
More information and source code: https://github.com/andreas-schwab-swx/dd_image
Leave a Reply
You must be logged in to post a comment.