I am messing with a backup script that I have and ran into issue. In this case I want to extract the directories and files that I want to backup from a file. I have a file named: include_dirs which includes a short list of files and directories for testing.
include_dirs:
Code:
/home/testuser/
/home/testuser/file1
/home/testuser/file2
/home/testuser/file3
Code:
dirs=include_dirs # the files and directories I want to back up
date=$(date +%m%d%y)
cat $dirs | while read lines
do
echo $lines| cpio -oavc > /home/testuser/extract/full$date.cpio 2> /home/testuser/extract/full_status$date.log
done
When I run it I get: ----> I truncated the other gargage
Code:
ksh -x ./test_backup full
+ dirs=include_dirs
+ [[ -d /home/testuser/extract ]]
+ [[ full == full ]]
+ read directories
+ cat include
+ cpio -oavc
+ echo /home/testuser/file1
+ 1> /home/testuser/extract/full101011.cpio 2> /home/testuser/extract/full_status101011.log
+ read directories
+ cpio -oavc
+ echo /home/testuser/file2
+ 1> /home/testuser/extract/full101011.cpio 2> /home/testuser/full_status101011.log
It keeps recreating the cpio file and then eventually ends. I think it has something to due with echoing the file and then piping it to cpio. Would this suffice:
Code:
dirs=include_dirs # the files and directories I want to back up
date=$(date +%m%d%y)
cat $dirs | while read lines
do
cat $lines| cpio -oavc < $lines > /home/testuser/extract/full$date.cpio 2> /home/testuser/extract/full_status$date.log
done
??