====== Python + amlabel = Bulklabeling! ====== A while ago, we upgraded all 50 backup tapes in the tape library at work from LTO-2 to LTO-3. This of course meant unpacking, inserting and labeling those tapes, both physically as well as electronically. While the physical labeling could not be automated((although we fooled around with the idea of using some Mind Storms construction for this while I waited for all the labels to be printed on the label machine)), I finally sat down to at least make the electronic labeling using [[http://www.amanda.org/|amanda's]] amlabel a little bit less unworthy of a sysadmin ;-) The result was a small python script((heavily influenced by [[http://demod.org/qh/python#frmtget.py|demod's frmtget]])) capable of bulk labeling a bunch of tapes based on a formatstring pattern of the label format that at least works perfectly fine in our environment -- YMMV ;-) I decided to post it here nevertheless as it might be of help for somebody out there besides us((and even if it's just for use as an example of how to use the [[http://docs.python.org/lib/module-optparse.html|OptionParser]] module of Python ;-))). Some basic usage instructions, the code and a download link follow. ===== Usage ===== Usage is quite simple. Given your labels are something like ''TAPE01'' or ''BACKUP_042'', the formatstring would be ''TAPE%02i'' or ''BACKUP_%03i''. So if you e.g. want to label five tapes using the above ''BACKUP'' format (and amanda's BACKUP config), starting with tape 42 which is located in physical slot 23 of your library, the tapelabel call would be ''tapelabel -f 23 -c 5 BACKUP BACKUP_%03i 42''. For more info, see ''tapelabel --help'': Usage: tapelabel [options] config formatstring number Options: --version show program's version number and exit -h, --help show this help message and exit -v, --verbose verbose output, use multiple times for spam -q, --quite suppress output, use multiple times for silence -f FIRSTSLOT, --firstslot=FIRSTSLOT specifies slot of first tape to label [default: '1'] -l LASTSLOT, --lastslot=LASTSLOT specifies slot of last tape to label -c COUNT, --count=COUNT specifies count of tapes to label [default: 'none'] -F, --force force writing of label --dry-run simulates run ===== Code and Download ===== {{:snippets:tapelabel.py.txt|Download}} {{tag>amanda amlabel script python code snippet selfcoded backup administration tool}} ~~LINKBACK~~ ~~DISCUSSION~~