Page 1 of 1

Files truncated after restore from cpio backup

Posted: 27. Oct 2012, 00:29
by GJones
I wrote the following very simple backup script:

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
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?

Re: Files truncated after restore from cpio backup

Posted: 29. Oct 2012, 07:49
by gapan
Could it be the same problem as this? http://www.salixos.org/forum/viewtopic.php?f=15&t=4077

Re: Files truncated after restore from cpio backup

Posted: 29. Oct 2012, 20:43
by GJones
Possible, but I don't think so - cpio shouldn't use gamin/FAM at all, and the archived files should not have been changing.