Problem
I need to compare the contents of my tape with the actual
listing of my folders. Is there an easy way to do this?I use a 'find' and 'cpio' command to backup my data, similar to:
TA#116623, "Where can I find a simple backup script to backup my server onto a tape on a nightly basis?"
Solution
By default the output of "cpio -itvc -I<backup media>" will result in an output similar to:
drwxr-xr-x 2 root sys 0 Jun 10 13:58 2008, test
-rwx------ 1 root sys 73 Jun 10 12:11 2008, test/testit
-rw-r--r-- 1 root sys 0 Jun 10 11:41 2008, test/0
-rw-r--r-- 1 root sys 0 Jun 10 11:41 2008, test/1
-rw-r--r-- 1 root sys 0 Jun 10 11:41 2008, test/2
-rw-r--r-- 1 root sys 0 Jun 10 11:41 2008, test/3
-rw-r--r-- 1 root sys 0 Jun 10 11:41 2008, test/4
-rw-r--r-- 1 root sys 0 Jun 10 11:41 2008, test/5and a 'find' will result in output similar to:
./test
./test/testit
./test/0
./test/1
./test/2
./test/3
./test/4
./test/5So performing a 'diff' will be difficult, so in order to
make the outputs match use the following syntax:# cpio -itVc -Itest.cpio > mycpio.txtWill result in an output similar to:
test
test/testit
test/0
test/1
test/2
test/3
test/4
test/5Next run a matching find command, for example:
cd /local ; find . -print > /tmp/find.txtWill result in an output similar to:
./test
./test/testit
./test/0
./test/1
./test/2
./test/3
./test/4
./test/5To remove the ./ at the front of the command, run:
# sed -e 's/^.\///' find.txt > myfind.txtWill result in an output similar to:
test
test/testit
test/0
test/1
test/2
test/3
test/4
test/5Now:# ls -al my*.txt
-rw-r--r-- 1 root sys 954827 Oct 15 18:01 mycpio.txt
-rw-r--r-- 1 root sys 954827 Oct 15 18:00 myfind.txtNext run, the 'diff' command:# diff mycpio.txt myfind.txtand, this will display the differences between your cpio archive and server files.