Ultimate BackUP script for partitions and disks

Technology, computers, networking, software, trashing your phone, and so on.
Post Reply
User avatar
molly
Posts: 69
Joined: Sat Apr 18, 2026 6:54 am

Ultimate BackUP script for partitions and disks

Post by molly »

With inspiration form diggy’s guide here https://digdeeper.love/articles/backup.xhtml I have created an ultimate backup script.

Currently this script is for Testing only, do not use it to backup critical data.
Updated script 30-07-2026 with bug fixes
Download it here-

https://digdeeper.rodeo/insert-coin/the ... ckup_2.inv

Once downloaded rename the file to ultimate_backup.sh

The script is based on Clonezilla but with a nicer user interface and some extra options.
What it does-

1. Backup – with partclone (clonezilla), with dd, compression= zst, gz, xz, bz2 and it has the option to shrink the unused space at the end of the partition, on ext4 partitions, thanks diggy!
Can backup as=
1) Partition images (all or selected partitions on the disk)
2) Full Disk image (entire block device)

2. Restore - Restore full disk, restore all partitions on disk, restore some or a single partition to a disk in both original position or any blank spot. Also if it is and ext4 partition you can choose to restore them to the original size with blank spaces or restore to the shrunken size without the blank space.
3. Mount – Mount your backed up disks / partitions so you can access files without having to restore them to a new disk.
4. List Partition Info. of your backed up disks / partitions.

To use-
For backing up=
put the script in the location you want your backup saved then run with ./ultimate_backup.sh
For restore=
put the script in the directory of your backup and run with ./ultimate_backup.sh
For mount=
put the script in the directory of your backup and run with ./ultimate_backup.sh

Feel free to test it out, if you find any bugs report them here.

system dependencies for full function-

Debian / Ubuntu
sudo apt install bash coreutils util-linux gawk sed grep findutils sudo \
gdisk parted partclone e2fsprogs dosfstools ntfs-3g xfsprogs btrfs-progs \
exfatprogs f2fs-tools zstd gzip xz-utils bzip2 pv pigz lbzip2

Arch / Archcraft
sudo pacman -S --needed bash coreutils util-linux gawk sed grep findutils sudo \
gptfdisk parted partclone e2fsprogs dosfstools ntfs-3g xfsprogs btrfs-progs \
exfatprogs f2fs-tools zstd gzip xz bzip2 pv pigz pbzip2

Dependencies

Required — the script won't start without these:

| Package (Arch) | Package (Debian/Ubuntu) | Provides |
|---|---|---|
| `bash` ≥ 4.3 | `bash` | namerefs, associative arrays |
| `coreutils` | `coreutils` | dd, stat, sort, head, tail, df, truncate, numfmt |
| `util-linux` | `util-linux` | lsblk, blkid, losetup, mount, umount, findmnt, partx, blockdev, sfdisk |
| `gawk` `sed` `grep` `findutils` | same | text processing |
| `sudo` | `sudo` | privileged operations |
| `gptfdisk` | `gdisk` | **sgdisk** — partition creation |
| `parted` | `parted` | parted, **partprobe** |
| `partclone` | `partclone` | partclone.* engines |
| `e2fsprogs` | `e2fsprogs` | e2fsck, resize2fs, tune2fs, e2label |

Needed per filesystem you actually touch:
- ext2/3/4 — `e2fsprogs` (required above; also what shrink/grow needs)
- FAT/vfat — `dosfstools` (fsck.fat, fatlabel)
- NTFS — `ntfs-3g` (ntfsfix, ntfslabel, ntfsinfo, ntfs-3g)
- XFS — `xfsprogs` · Btrfs — `btrfs-progs` · exFAT — `exfatprogs` · F2FS — `f2fs-tools`

Compression — install whichever you'll use:
`zstd`, `gzip`, `xz` (Debian: `xz-utils`), `bzip2`. Each is checked only when an image actually needs it, so a missing one never blocks unrelated work.

Optional but recommended:
- `pv` — progress bars (without it you get a spinner)
- `pigz`, `pbzip2` or `lbzip2` — parallel decompression in the mount module
- `smartmontools`, `hdparm` — not used, but useful alongside
Last edited by molly on Thu Jul 30, 2026 4:43 am, edited 6 times in total.
User avatar
digdeeper
Posts: 241
Joined: Tue Feb 17, 2026 2:56 pm
Contact:

Re: Ultimate BackUP script for partitions and disks

Post by digdeeper »

Choosing the option to shrink the partition throws the error "ERROR: parted recreate failed for /dev/sdaX" and destroys the partition. Sorry for making this public but I don't want anyone to wreck himself. I recommend to only use it for testing, for now.
User avatar
molly
Posts: 69
Joined: Sat Apr 18, 2026 6:54 am

Re: Ultimate BackUP script for partitions and disks

Post by molly »

Thank you for the feedback, this is why it's posted to find problems. I have updated the post, try installing the dependents for your system.
User avatar
molly
Posts: 69
Joined: Sat Apr 18, 2026 6:54 am

Re: Ultimate BackUP script for partitions and disks

Post by molly »

Updated script with bug fixes. Should now work with slackware, no more partition destruction after shrinking and all other know bugs fixed, plus improved user interaction.
Will also alert for Dependencies and won't crash with if missing.
See first post for download link.
User avatar
digdeeper
Posts: 241
Joined: Tue Feb 17, 2026 2:56 pm
Contact:

Re: Ultimate BackUP script for partitions and disks

Post by digdeeper »

I can confirm that at least the partition isn't wrecked anymore. I'll do more testing with restore etc. later.

BTW, I don't know if the progress bar is supposed to display while shrinking, but it isn't. For a while I thought nothing is being done.
Post Reply