Tech Blog

These are blog entries written by the UNIX Health Check development team. Our team has extensive technical experience on both AIX and Red Hat systems, and we like to share our knowledge with our visitors.

Topics: AIX, Backup & restore, Performance

Using a pipeline

The next part describes a problem where you would want to do a search on a file system to find all directories in it, and to start a backup session per directory found, but not more than 20 backup sessions at once. Usually you would use the "find" command to find those directories, with the "-exec" parameter to execute the backup command. But in this case, it would result in possibly more than 20 active backup sessions at once, which might overload the system.

So, you can create a script that does a "find" and dumps the output to a file first, and then starts reading that file and initiating 20 backups in parallel. But then, the backup can't start, before the "find" command completes, which may take quite a long time, especially if run on a file system with a large number of files. So how do you do "find" commands and backups in parallel? Solve this problem with a pipeline.

Create a pipeline:

# rm -f /tmp/pipe
# mknod /tmp/pipe p
Issue the find command:
# find [/filesystem] -type d -exec echo {} \; > /tmp/pipe
So now you have a command which writes to the pipeline, but can't continue until some other process is reading from the pipeline.

Create another script that reads from the pipe and issues the backup sessions:
cat /tmp/pipe | while read entry
do
   # Wait until less than 20 backup sessions are active
   while [ $(jobs -p|wc -l|awk '{print $1}') -ge 20 ]
   do
      sleep 5
   done

   # start backup session in the background
   [backup-command] &
   echo Started backup of $entry at `date`
done
# wait for all backup sessions to end
wait
echo `date`: Backup complete
This way, while the "find" command is executing, already backup sessions are started, thus saving time to wait until the "find" command completes.

Topics: AIX, Backup & restore, NIM

Nimesis

If you're trying to restoring an mksysb through NIM and constantly get the same error when trying to restore a mksysb on different systems:

0042-006 niminit (To-master) rcmd connection refused
This may be caused by the "nimesis" daemon not running on the NIM server. Make sure it's enabled in /etc/inittab on the NIM server:
# grep nim /etc/inittab
nim:2:wait:/usr/bin/startsrc -g nim >/dev/console 2>&1

Number of results found for topic Backup & restore: 42.
Displaying results: 41 - 42.