Full system backup with SquashFS
Compressed backup archives of whole filesystems can be made in the SquashFS format. Backup and retrieval takes relatively less time with its random access capability, but any kind of modification other than appending is not yet possible.
Device File | Description |
---|---|
/dev/sdB | Backup Drive |
/dev/sdL | Live Medium |
/dev/sdSRC | Drive to Be Backed Up |
Pros and cons
Pros:
- No partitioning, no guessing how much size is required
- SquashFS should be supported by most rescue disks
- Random access[citation needed], with a plain
mount
- Duplicate files are removed by default (unless
-no-duplicates
flag is on)
Cons:
- Access Control Lists are not yet supported, and therefore not backed up
- Not accessible from Windows1
- Appendable but impossible to remove things from it
- To use the disk for some other purposes, you have to destroy the backup2
Note:
- squashfs-tools-ng may support SquashFS image files but Windows itself does not support partitionless drives at all.
- Do not grab the lifebuoy when you need a swim ring. File sharing and backup should be in separate disks. Please buy adequate backup hardware.
Prepare the backup drive
Warning:
- All data on the backup drive will be lost.
- All data on machine may be lost if an incorrect device file is specified.
- Wipe out all partitions
/dev/sdBN
, then the partition table/dev/sdB
, with wipefs. - Synchronize all write caches
# sync
- Inform the OS of partition table changes
- Check for bad blocks:
- If the backup drive is an SSD, use S.M.A.R.T..
- If the backup drive is an HDD, use badblocks.
Prepare a live medium
Installation guide#Prepare an installation medium or archiso to /dev/sdL
Note: Creating SquashFS filesystem requires squashfs-tools, which is included in the official Arch Linux installation image.
Back up
Installation guide#Boot the live environment
Mount filesystems you would like to backup. (e.g. /dev/sdSRC to /mnt)
Back up (example script)
- -not-reproducible
- Slightly increase backup speed
- -noappend
- Overwrite
- -mem
- RAM granted to mksquashfs
- -e
- List of exclude dirs/files
(Optional) Test backup in QEMU
Grant permission
$ sudo chown $USER:$USER /dev/sdB
Launch QEMU
$ qemu-system-x86_64 \ -kernel /boot/vmlinuz-linux \ -append "root=/dev/sdB ro loglevel=3 init=/usr/lib/systemd/systemd" \ -initrd /boot/initramfs-linux-fallback.img \ -drive file=/dev/sdB,index=0,media=disk,format=raw \ -m ''virtual_machine_ram_in_MiB'' \ --enable-kvm \ -cpu host
(Optional) Inspect backup
Get backup date
# date --date=@"$(unsquashfs -mkfs-time /dev/sdB)"
More superblock information
# unsquashfs -stat /dev/sdB
Checksum
Retrieve file from backup
# mount /dev/sdB /mnt # cp /mnt/path/to/file /path/to/destination
This article is issued from Archlinux. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.