Files truncated after restore from cpio backup
Posted: 27. Oct 2012, 00:29
I wrote the following very simple backup script:
It worked, and I was able to transplant my system to another computer! But on reboot I discovered that ldconfig would segfault whenever I ran it. Running gdb on ldconfig revealed that the executable was truncated - it had been corrupted during the backup. I had to reinstall glibc... And who knows what else broke as well.
How did this happen? I was not running any updates during the backup - glibc and other system files should have been completely untouched.
P.S. I used cpio instead of tar because the Busybox version of tar on the 13.37 install CD is broken - it doesn't restore symlinks properly. Maybe the Busybox cpio is also broken?
Code: Select all
#!/bin/sh
# backup.sh - a primitive backup script
# Purpose: online backup for desktops
# Usage:
# backup.sh /path/to/backups
#
backup_name=system-backup-$(date +"F").cpio.bz2
find / \
! -path "/tmp/*" \
! -path "/sys/*" \
! -path "/proc/*" \
! -path "/home/*" \
! -path "/dev/*" \
! -name "lost+found" \
! -name $backup_name | cpio -o -H newc | bzip2 -c \
> $1/system-backup-$(date +"%F").cpio.bz2
How did this happen? I was not running any updates during the backup - glibc and other system files should have been completely untouched.
P.S. I used cpio instead of tar because the Busybox version of tar on the 13.37 install CD is broken - it doesn't restore symlinks properly. Maybe the Busybox cpio is also broken?