Redirected Restore Rename Chunks Script
Posted in 2008
Here is a shell script to help generate a chunk map file for use when trying to perform a redirected restore to an instance on the same server. My first attempt at this did not take into consideration the rootdbs being mirrored so I spent 3 days chasing my tail and wondering why the source instance was being corrupted by the restore of the new instance when I seemed to be doing everything right.
Hopefully this will help someone out and keep them from wasting 3 days of their life on such a trivial oversight.
<CHUNKLIST SCRIPT>
search1=$1
search2=$2
echo "UNLOAD TO chklist
SELECT
TRIM(fname) || ' '
|| ROUND((offset * (pagesize / 1024)),0) || ' '
|| TRIM(REPLACE(fname, '$search1', '$search2')) || ' '
|| ROUND((offset * (pagesize / 1024)),0)
FROM syschunks
UNION
SELECT
TRIM(mfname) || ' '
|| ROUND((offset * (pagesize / 1024)),0) || ' '
|| TRIM(REPLACE(mfname, '$search1', '$search2')) || ' '
|| ROUND((offset * (pagesize / 1024)),0)
FROM syschunks
WHERE mfname IS NOT NULL
"|dbaccess sysmaster
cat chklist | sed -e 's/|//g' > $$.tmp
mv $$.tmp chklist
</CHUNKLIST SCRIPT>