Squashfs Backup Demo

by Ramses Soto-Navarro ramses@sotosystems.com, 2/1/2022


Overview
Mount squashfs file
Interactive shell
Release session
Prepare Server for Backup
SSHFS remote mount
Squash Backup


Overview

What is squashfs:

  • Squashfs is an archiver like tar.
  • Archives data onto backup file.
  • Allows quick read access of file backups.
  • High compression.
  • Can be mounted.
  • Can be appended.
  • Random seek, rather than linear.
  • Very quick access.
  • Used in embedded systems, cellphones, routers, livecd.
  • 7-zip supports squashfs.

The squashfs mount enables us to:

  • Archive the entire old server in a compressed file.
  • Mount the squashfs file and easily review files and directories.
  • Copy files from the old servers.
  • Run an interactive shell session of the old server.
  • Append more files to the backup file as needed.

Audience is experienced Linux administrators.

Mount a squashfs file

Mount an old www server squashfs file.

ssh server1
sudo su -
mkdir -p /backup/www-old
mount /backup/backup-www-old.sqfs /backup/www-old/
umount /backup/www-old

Interactive shell

Chroot into an interfactive shell.

cd /backup/cid-old
mount -o bind /dev dev
mount -o bind /sys sys
mount -o bind /proc proc
chroot . /bin/bash

Release session

exit
umount dev
umount sys
umount proc
cd /mnt
umount /mnt/root/boot
umount /mnt/root

Prepare Server for Backup

* Start the server in rescue mode using the installation media.
* Activate Linux LVM,

vgscan ; vgchange -ay

* Mount the root directory:

vgs
lvs
mkdir -p /mnt/root
mount /dev/vg1/lvroot /mnt/root

* Mount the boot directory:

mount /dev/sda1 /mnt/root/boot

* Mount the rest of the directories:

cat /mnt/root/etc/fstab

* Activate networking:

cat /mnt/root/etc/sysconfig/network/ifcfg-eth0
cat /mnt/root/etc/sysconfig/network/routes
ifconfig eth0 10.10.10.10 netmask 255.255.255.0
route add default gw 10.10.10.1

* Activate ssh:

service sshd start
passwd

SSHFS remote mount

mkdir /mnt/oldserver
sshfs -o ro 10.10.10.10:/mnt/root/ /mnt/oldserver/

Squash Backup

* Squashfs old server in rescue mode:

cd /mnt/oldserver
mksquashfs . /backup/oldserver.sqfs

The End.

  1. promoCed

    Wednesday, October 26, 2022 - 01:59:52

    Earlier I thought differently, thanks for an explanation.