S
S
Sergey Karbivnichy2022-01-11 20:52:50
linux
Sergey Karbivnichy, 2022-01-11 20:52:50

How to add empty folders to an archive using mksquashfs?

Made a script for system backup. Everything works, but it delivers some inconvenience when restoring the archive. When archiving, the script excludes the following directories - home media dev run mnt proc sys tmp. So, if you unpack the archive to a clean partition, and at the same time do not manually create at least one of the following directories - dev run proc sys- then the kernel panics and does not boot. Is it possible to add something to my script so that these directories are also archived, but without elements inside.
The script itself:

filename=system_$(date +"%d_%m_%Y-%H_%M").sq
echo -n "Сделать резервную копию системы (y/n)? "
read answer

if [ "$answer" != "${answer#[Yy]}" ] ;then
    mksquashfs / /$filename -e $filename home media dev run mnt proc sys tmp /opt/wine-devel /opt/lampp /opt/yandex
else
    echo No
fi

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Aleksandrov, 2022-01-11
@jamakasi666

Why the hell are you squashing to unpack? Squash is a full-fledged fs in ro, maybe you should use archives, now zstd is very cool?
On the topic, well, in addition to the packaging script, also make an unpacking script where you create the missing structure.
And off topic, once you contacted squash, but you can make it a little more interesting and more convenient. Add (or take a ready-made) initrd that will do
1) mount the squash somewhere
2) mount the overlay on top of the squash and into the new root partition for the OS. And if there is enough RAM, then even in zram
3) continue to boot the OS
4) Write a backup script that makes a fresh version of the current system, puts it where it needs to, creates a boot record for it.
The output will be an indestructible system with direct backups and their loading, and even optionally from the bootloader. What screwed up? just rebooted and everything rolled back. Updated / installed and is it good and necessary? made a backup, wiped unnecessary old backups leaving the necessary ones.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question