Hello,
My Problem
I am using rsync to backup my Ubuntu 22.04 server running on an SD Card in a Raspberry Pi. I run the backup when Ubuntu is also running with this command:
> rsync -aDH --partial --numeric-ids --delete --force --exclude "${MNTPATH}" --exclude '/dev' --exclude '/lost+found' --exclude '/media' --exclude '/mnt' \ > --exclude '/proc' --exclude '/run' --exclude '/sys' --exclude '/tmp' --exclude '/var/swap' --exclude '/etc/udev/rules.d/70-persistent-net.rules' \ > --exclude '/var/lib/asterisk/astdb.sqlite3-journal' "${OPTIONS[@]}" / "${MNTPATH}/"
So all (I think) of the directories whose content appears at runtime only are excluded from the backup.
HOWEVER… my resulting backup is always a lot bigger than I would expect. The backup is created using rsync on to a image file (the truncate
command) that is partitioned and formatted (boot partition as fat32 and root partition as ext4).
Trying to Debug
When I loopmount this image file and also take out the Ubuntu server sd card and mount them both separately in my laptop I get this:
The root partition on the backup image… it has been loop device mounted in my laptop running Manjaro.
[flex@flex~]$ sudo du -hs /media/writable/
4.8G /media/writable/
The root partition on the SD Card containing the OS that the backup was made from with that SD Card removed from the Pi.
[flex@flex~]$ sudo du -hs /media/writable1/
3.3G /media/writable1/
Why is the backup 1.5GB bigger than the original it was made from? The backup should be smaller because it excluded a lot of runtime directories from Ubuntu running on the sd card.
More Debugging
I ran this rsync command to double check if some mysterious extra files were being created on the destination that are not on the source or were the same files getting bigger when they were on the destination compared with them on the source:
sudo rsync -nrlpgoDv --delete --exclude-from='/home/ubuntu/exclude-list.txt' / /mnt/dst_root/
/home/ubuntu/exclude-list.txt
dev
lost+found
media/4TB1
mnt
proc
run
sys
tmp
But I don’t see any big differences between the source and destination in terms of numbers of files or the size they occupy in source vs destination.
Snap is installed
ubuntu@ubuntu:/snap$ ls -l
total 20
-r--r--r-- 1 root root 548 Apr 19 11:11 README
drwxr-xr-x 2 root root 4096 May 21 21:30 bin
drwxr-xr-x 4 root root 4096 May 27 17:19 core20
drwxr-xr-x 4 root root 4096 May 21 21:30 lxd
drwxr-xr-x 4 root root 4096 May 27 17:18 snapd
ubuntu@ubuntu:/snap$ snap list
Name Version Rev Tracking Publisher Notes
core20 20220512 1498 latest/stable canonical* base
lxd 5.0.0-b0287c1 22927 5.0/stable/… canonical* -
snapd 2.55.5 15909 latest/stable canonical* snapd
ubuntu@ubuntu:/snap$ df -h
Filesystem Size Used Avail Use% Mounted on
tmpfs 379M 4.7M 375M 2% /run
/dev/mmcblk0p2 30G 3.7G 25G 13% /
tmpfs 1.9G 0 1.9G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
/dev/mmcblk0p1 253M 148M 105M 59% /boot/firmware
/dev/sda1 3.6T 1.3T 2.2T 37% /media/4TB1
ubuntu@ubuntu:/snap$ sudo losetup -a
/dev/loop1: [45826]:1392 (/var/lib/snapd/snaps/core20_1498.snap)
/dev/loop4: [45826]:7068 (/var/lib/snapd/snaps/snapd_15541.snap)
/dev/loop2: [45826]:77516 (/var/lib/snapd/snaps/lxd_22915.snap)
/dev/loop0: [45826]:7407 (/var/lib/snapd/snaps/core20_1437.snap)
/dev/loop5: [45826]:7773 (/var/lib/snapd/snaps/snapd_15909.snap)
/dev/loop3: [45826]:7426 (/var/lib/snapd/snaps/lxd_22927.snap)
My Theory
Is this because of snap? Maybe because when I rsync from Ubuntu I copy snap installation and data files and settings which exist in squashfs file system which is compressed and so on the destination they take up less space?
Any advice much appreciated.
Cheers,
flex